Compare commits

...

71 Commits

Author SHA1 Message Date
Anna “CyberTailor” f2c0a5cb40
Update description
continuous-integration/drone/push Build is passing Details
2024-01-11 10:03:42 +05:00
Anna “CyberTailor” 6f036a8331
docs: document code style
continuous-integration/drone/push Build is passing Details
2024-01-11 10:00:25 +05:00
Anna “CyberTailor” aaf142eecf
docs: describe development status 2024-01-11 09:48:22 +05:00
Anna “CyberTailor” f5db071e0c
github: add funding info
continuous-integration/drone/push Build is passing Details
2024-01-07 00:35:48 +05:00
Anna “CyberTailor” ba8fce7203
docs: add Git button
continuous-integration/drone/push Build is passing Details
2024-01-04 08:55:56 +05:00
Anna “CyberTailor” 8cd6357930
readme: add OpenSSF Best Practices badge 2024-01-04 08:36:16 +05:00
Anna “CyberTailor” 86d2ed0de8
docs: fix typo 2024-01-04 08:15:12 +05:00
Anna “CyberTailor” e1d9a6bcfe
ChangeLog: sync
continuous-integration/drone/push Build is passing Details
2023-11-25 14:17:40 +05:00
Anna “CyberTailor” d8f2d4c281
docs: restructure toctree 2023-11-25 14:16:46 +05:00
Anna “CyberTailor” 4ab76f13f9
docs: add gitweb link 2023-11-25 13:55:27 +05:00
Anna “CyberTailor” 9597fe7c4a
docs: update build steps 2023-11-25 13:39:31 +05:00
Anna “CyberTailor” f002d84823
docs: explain why 2023-11-25 13:34:19 +05:00
Anna “CyberTailor” dc4f35239e
docs: fix configuration 2023-11-25 13:31:01 +05:00
Anna “CyberTailor” 9a2b8badb4
docs: correct build deps 2023-11-25 12:38:59 +05:00
Anna “CyberTailor” 30cb8eb5ef
fixup
continuous-integration/drone/push Build is passing Details
2023-11-22 04:44:24 +05:00
Anna “CyberTailor” 84065e8d7f
docs: new Matrix room address 2023-11-22 04:41:30 +05:00
Anna “CyberTailor” ed8f9d79e1
Bump version: 1.1.2 → 1.1.3
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2023-06-17 12:52:30 +05:00
Anna “CyberTailor” f2513f9ea0
man: fix a file collision 2023-06-17 12:52:25 +05:00
Anna “CyberTailor” f8b92cf59a
Fix reuse
continuous-integration/drone/push Build is passing Details
2023-06-08 07:26:58 +05:00
Anna “CyberTailor” a3167b7dc1
ci: add reuse lint
continuous-integration/drone/push Build is failing Details
2023-06-08 00:35:28 +05:00
Anna “CyberTailor” 06009bcf1c
Fix reuse 2023-06-08 00:33:51 +05:00
Anna “CyberTailor” 7c5b3662d5
Bump version: 1.1.1 → 1.1.2
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2023-05-28 16:56:12 +05:00
Anna “CyberTailor” 29e0be98f2
Add .bumpversion.cfg 2023-05-28 16:55:19 +05:00
Anna “CyberTailor” cbcaecbbe1
nimbus.nim: re-add variable 2023-05-28 16:42:46 +05:00
Anna “CyberTailor” 37683413b5
ci: add a step for Sphinx docs
continuous-integration/drone/push Build is passing Details
2023-05-08 09:22:34 +05:00
Anna “CyberTailor” 6579676c0e
docs: make some extensions optional
continuous-integration/drone/push Build is passing Details
2023-05-06 22:48:11 +05:00
Anna “CyberTailor” d89feb27f7
Add build status to README.md
continuous-integration/drone/push Build is passing Details
2023-05-02 19:24:02 +05:00
Anna “CyberTailor” 83c1c131b4
Update README.md 2023-05-02 19:21:43 +05:00
Anna “CyberTailor” f1253a54ff
ci: add Drone CI
continuous-integration/drone/push Build is passing Details
2023-05-02 19:14:23 +05:00
Anna “CyberTailor” 7fdb965f5d
testerscript.nim: disable warnings 2023-05-02 18:32:43 +05:00
Anna “CyberTailor” b4ca001a03
testerscript.nim: change nim cache directory for tests 2023-05-02 18:26:32 +05:00
Anna “CyberTailor” f2176b4b6f
docs/conf.py: update version 2023-05-02 18:09:21 +05:00
Anna “CyberTailor” 691614ddf4
docs: keep empty directories 2023-05-02 17:57:47 +05:00
Anna “CyberTailor” d925245830
tag 1.1.1 2023-04-27 23:12:32 +05:00
Anna “CyberTailor” ec9e3f7030
testerscript.nim: fix 2023-04-27 23:10:06 +05:00
Anna “CyberTailor” 183c021d9f
tag 1.1.0 2023-04-27 23:00:30 +05:00
Anna “CyberTailor” 8371e7918c
nimbus.nim: use custom jsonscript executor
Work around https://github.com/nim-lang/Nim/issues/21741
2023-04-27 23:00:30 +05:00
Anna “CyberTailor” 9d03584047
nimbus.nim: separate Nim cache by binary 2023-04-27 22:48:19 +05:00
Anna “CyberTailor” 38938e5550
nimbus.nimble: add clean task 2023-04-27 22:35:06 +05:00
Anna “CyberTailor” 20a35e68a3
tests/*: refine directory structure 2023-04-27 22:35:06 +05:00
Anna “CyberTailor” 10b0b6501b
nimbus.nim: use a custom build script 2023-04-27 22:35:06 +05:00
Anna “CyberTailor” f43973d392
ninjasyntax.nim: don't escape build() args 2023-04-27 22:19:16 +05:00
Anna “CyberTailor” ea0456c81b
txt2deps.nim: new utility 2023-04-27 22:18:54 +05:00
Anna “CyberTailor” 325bfa4fea
*/*: remove depfile support via patched Nim 2023-04-26 18:01:58 +05:00
Anna “CyberTailor” e5a9c7048c
nimbus.nim: do not disable hints for nimc 2023-01-08 03:40:15 +05:00
Anna “CyberTailor” 0cb15d80a3
nimbus.nim: enable live outpit for nimc 2023-01-08 03:22:23 +05:00
Anna “CyberTailor” 9854723ee4
docs/conf.py: add sphinx_sitemap 2022-11-13 20:11:22 +05:00
Anna “CyberTailor” cd484a637c
docs/*: add Sphinx docs 2022-11-13 19:38:17 +05:00
Anna “CyberTailor” 089cf83ef5
tag 1.0.0 2022-07-17 18:10:22 +05:00
Anna “CyberTailor” acb84dbf7b
README.md: add example use 2022-07-13 18:23:32 +05:00
Anna “CyberTailor” 435798bd59
README.md: link manpage 2022-07-13 17:05:51 +05:00
Anna “CyberTailor” 83d83cccac
nimbus.1: sync 2022-07-13 17:03:09 +05:00
Anna “CyberTailor” 9bc062b4ec
README.md: add Packaging section 2022-07-13 16:45:37 +05:00
Anna “CyberTailor” cadfd1ff7a
README.md: mention my nim-patches repo 2022-07-13 15:31:56 +05:00
Anna “CyberTailor” ceba2bdc85
nimbus.nim: tell Ninja to process dependencies 2022-07-13 15:10:43 +05:00
Anna “CyberTailor” d86ce2f26c
nimbus.nim: add depfile support 2022-07-13 15:07:36 +05:00
Anna “CyberTailor” 057853015c
options.nim: set default log level to NOTICE 2022-07-13 13:54:03 +05:00
Anna “CyberTailor” 4493dd5b7a
ChangeLog: tag 0.3.0 2022-07-13 13:19:57 +05:00
Anna “CyberTailor” a7e07ef2ab
nimbus.nim: add more debug messages 2022-07-13 13:18:21 +05:00
Anna “CyberTailor” 6adb7771d6
nim.cfg: switch to --gc:orc 2022-07-13 13:16:36 +05:00
Anna “CyberTailor” 62e98baa1f
nimbleexecutor.nim: query variables in bulk 2022-07-13 13:16:36 +05:00
Anna “CyberTailor” 2679338804
src/*: prefix standard imports with "std" 2022-07-13 08:11:30 +05:00
Anna “CyberTailor” 221820d53c
dependencyresolver.nim: make pkgList threadvar 2022-07-06 22:48:44 +05:00
Anna “CyberTailor” b54279811e
nimbleexecutor.nim: use "thread" pragma 2022-07-06 22:40:00 +05:00
Anna “CyberTailor” 6ae406ae6d
ChangeLog: tag 0.2.5 2022-07-04 23:24:14 +05:00
Anna “CyberTailor” de6948b137
packageinfo.nim: add debug info 2022-07-04 23:21:43 +05:00
Anna “CyberTailor” 37ed7e842c
dependencyresolver.nim: prefix unsupportedPkgWarning 2022-07-04 23:09:21 +05:00
Anna “CyberTailor” 86b1a530ab
nimbleexecutor.nim: add debug output 2022-07-04 23:03:40 +05:00
Anna “CyberTailor” 55dadc6702
packageinfo.nim: try to avoid deadlocks 2022-07-04 12:02:54 +05:00
Anna “CyberTailor” c00a7567fa
tests/packageinfo: rename some data files 2022-07-04 07:43:36 +05:00
Anna “CyberTailor” 69a0cda85b
*/*: mark some functions as having no side effect 2022-07-04 02:44:15 +05:00
121 changed files with 1517 additions and 467 deletions

10
.bumpversion.cfg Normal file
View File

@ -0,0 +1,10 @@
[bumpversion]
current_version = 1.1.3
commit = True
tag = False
[bumpversion:file:docs/conf.py]
[bumpversion:file:nimbus.nimble]
[bumpversion:file:src/nimbs/common.nim]

3
.bumpversion.cfg.license Normal file
View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Anna <cyber@sysrq.in>
SPDX-License-Identifier: CC0-1.0

34
.drone.yml Normal file
View File

@ -0,0 +1,34 @@
# SPDX-FileCopyrightText: 2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
kind: pipeline
type: docker
name: default
steps:
- name: test
image: nimlang/nim:alpine
commands:
- testament --megatest:off all
---
kind: pipeline
type: docker
name: sphinx-doc
steps:
- name: build
image: sphinxdoc/sphinx:latest
commands:
- pip install -r docs/requirements.txt
- sphinx-build docs docs/_build
---
kind: pipeline
type: docker
name: reuse-lint
steps:
- name: lint
image: fsfe/reuse:latest
commands:
- reuse lint

4
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2024 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: CC0-1.0
custom: "https://sysrq.in/en/donate.md"

2
.gitignore vendored
View File

@ -7,10 +7,12 @@
!*.*
!*/
!ChangeLog
!Makefile
# Any path
*.swp
*~
_build/
build/
nimcache/

View File

@ -1,10 +1,8 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: nimbus
Upstream-Contact: Anna <cyber@sysrq.in>
Source: https://nimbus.sysrq.in
Source: https://nimbus.sysrq.in/
# Sample paragraph, commented out:
#
# Files: src/*
# Copyright: $YEAR $NAME <$CONTACT>
# License: ...
Files: ChangeLog
Copyright: Nimbus contributors
License: CC0-1.0

View File

@ -1,12 +1,74 @@
2023-11-25 Anna <cyber@sysrq.in>
* Documentation fixes
2023-06-17 Anna <cyber@sysrq.in>
* man/txt2deps.1: fix filename
* 1.1.3 tagged
2023-05-28 Anna <cyber@sysrq.in>
* Add $sourcedir ninja variable (deleted by mistake)
* 1.1.2 tagged
2023-05-02 Anna <cyber@sysrq.in>
* testerscript.nim: change nim cache directory for tests
* testerscript.nim: disable warnings
* Add Drone CI
2023-04-27 Anna <cyber@sysrq.in>
* 1.1.0, 1.1.1 tagged
* ninjasyntax.nim (build): don't escape args automatically
* nimbus.nim: use a custom build script
* tests: refine directory structure
* nimbus.nimble: add clean task
* Use separate cache directories for each target
2023-04-25 Anna <cyber@sysrq.in>
* nimbus.nim: drop support for patched Nim compilers
* txt2deps: new utility
2022-07-13 Anna <cyber@sysrq.in>
* 0.3.0, 0.3.1 tagged
* nim.cfg: switch to --gc:orc, disable threads
* nimbleexecutor.nim (toJsonString): query variables in bulk
* nimbus.nim: support patched Nim compilers with --depfile option; add
debug output
* options.nim (initLogger): set default log level to NOTICE
2022-07-04 Anna <cyber@sysrq.in>
* 0.2.4 tagged
* 0.2.4, 0.2.5 tagged
* Implemented better quoting for generated NimScript and ninja.build.
* nimbleexecutor.nim (query): add debug output
* packageinfo.nim (initPackageInfo): use custom spawnX-like wrappers
to avoid spawning too much threads, add debug info
2022-07-02 Anna <cyber@sysrq.in>
* 0.2.0 tagged
* 0.2.0, 0.2.1, 0.2.2, 0.2.3 tagged
* Fixed build for binaries inside subdirectories.

156
LICENSES/CC-BY-4.0.txt Normal file
View File

@ -0,0 +1,156 @@
Creative Commons Attribution 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. Downstream recipients.
A. Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.

View File

@ -1,11 +1,24 @@
<!-- SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in> -->
<!-- SPDX-FileCopyrightText: 2022-2024 Anna <cyber@sysrq.in> -->
<!-- SPDX-License-Identifier: CC0-1.0 -->
nimbus
======
[![Build Status](https://drone.tildegit.org/api/badges/CyberTaIlor/nimbus/status.svg)](https://drone.tildegit.org/CyberTaIlor/nimbus)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8267/badge)](https://www.bestpractices.dev/projects/8267)
**nimbus** is a **Nim** **bu**ild **s**ystem. You can also call in NimBS. Nimja
would also be a clever name but it's already taken.
would also be a clever name but it's already taken (turns out the name "nimbus"
is taken two times already but nobody cares yet).
* [Read the manpage online][man]
* Example use:
* [nimble.eclass][nimble.eclass]
* [dev-nim/\* ebuilds][dev-nim]
[man]: https://docs.sysrq.in/nimbus
[nimble.eclass]: https://gitweb.gentoo.org/repo/proj/guru.git/tree/eclass/nimble.eclass
[dev-nim]: https://gitweb.gentoo.org/repo/proj/guru.git/tree/dev-nim
Raison d'être
@ -18,9 +31,21 @@ This project is intended to be used with traditional package managers (primarly
with Gentoo's Portage). But maybe it'll be useful for other purposes too.
Development status
------------------
This software is considered [completed][ddv-post] and stable. No new features
are planned, however there will be releases for bug fixes and compatibility
updates.
[ddv-post]: https://drewdevault.com/2021/01/04/A-culture-of-stability-and-reliability.html
Dependencies
------------
This software has no build dependencies other than the Nim standard library.
**nimbus** only generates `build.ninja` files, so you'll need [ninja][ninja]
or [samurai][samurai] to use it.
@ -35,9 +60,12 @@ Installing
`nimble install`
* Using just Nim compiler:
* Using just Nim compiler (expert):
`nim c src/nimbus`
```sh
nim c src/nimbus
nim c src/txt2deps
```
Testing
@ -48,11 +76,20 @@ $ testament all
```
Packaging
---------
You can track new releases using an [atom feed][atom] provided by GitHub.
[atom]: https://github.com/cybertailor/nimbus/releases.atom
Contributing
------------
Patches and pull requests are welcome. Please use either [git-send-email(1)][1]
or [git-request-pull(1)][2], addressed to <cyber@sysrq.in>.
Patches and pull requests are welcome. Please use either
[git-send-email(1)][git-send-email] or [git-request-pull(1)][git-request-pull],
addressed to <cyber@sysrq.in>.
Your commit message should conform to the following standard:
@ -66,8 +103,8 @@ sure to reference any bug reports and other contributors. Make
sure the correct authorship appears.
```
[1]: https://git-send-email.io/
[2]: https://git-scm.com/docs/git-request-pull
[git-send-email]: https://git-send-email.io/
[git-request-pull]: https://git-scm.com/docs/git-request-pull
IRC
@ -77,7 +114,7 @@ You can join the `#nimbus` channel either on [OFTC][oftc] or
[via Matrix][matrix].
[oftc]: https://www.oftc.net/
[matrix]: https://matrix.to/#/#nimbus:matrix.org
[matrix]: https://matrix.to/#/#nimbus:sysrq.in
License

23
docs/Makefile Normal file
View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: CC0-1.0
#
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

1
docs/_templates/git-alt.svg vendored Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path opacity="1" fill="#1E3050" d="M439.6 236.1L244 40.5a28.9 28.9 0 0 0 -40.8 0l-40.7 40.6 51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.2 199v121.9c25.3 12.5 22.3 41.9 9.1 55a34.3 34.3 0 0 1 -48.6 0c-17.6-17.6-11.1-46.9 11.3-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1a28.9 28.9 0 0 0 0 40.8l195.6 195.6a28.9 28.9 0 0 0 40.8 0l194.7-194.7a28.9 28.9 0 0 0 0-40.8z"/></svg>

After

Width:  |  Height:  |  Size: 684 B

3
docs/_templates/git-alt.svg.license vendored Normal file
View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Fonticons, Inc.
SPDX-License-Identifier: CC-BY-4.0

3
docs/_templates/git-button.html vendored Normal file
View File

@ -0,0 +1,3 @@
<a href="{{ git_repo_url }}" title="Git Repository">
{% include 'git-alt.svg' %}
</a>

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 Anna (cybertailor) Vyalkova <cyber@sysrq.in>
SPDX-License-Identifier: CC0-1.0

66
docs/conf.py Normal file
View File

@ -0,0 +1,66 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: CC0-1.0
#
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'nimbus'
author = 'Anna (cybertailor) Vyalkova & Nimble Authors'
copyright = f'2022-2023, {author}'
release = '1.1.3'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx_prompt',
]
try:
import notfound.extension
extensions.append('notfound.extension')
notfound_urls_prefix = None
except ModuleNotFoundError:
pass
try:
import sphinx_sitemap
extensions.append('sphinx_sitemap')
sitemap_locales = [None]
sitemap_url_scheme = '{link}'
except ModuleNotFoundError:
pass
root_doc = 'toc'
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
manpages_url = 'https://docs.sysrq.in/{path}'
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'insipid'
html_permalinks_icon = '#'
html_theme_options = {
'globaltoc_maxdepth': 3,
'right_buttons': ['git-button.html'],
}
html_sidebars = {
'**': [
'globaltoc.html',
]
}
html_context = {
'git_repo_url': 'https://git.sysrq.in/nimbus/about/',
}
html_static_path = ['_static']
html_title = f'{project} {release}'
html_baseurl = 'https://nimbus.sysrq.in/'

54
docs/contributing.rst Normal file
View File

@ -0,0 +1,54 @@
.. SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
..
.. SPDX-License-Identifier: BSD-3-Clause
Contributing
============
Any form of contribution is welcome!
Workflow
--------
First, get the source code:
.. prompt:: bash
git clone https://git.sysrq.in/nimbus
Make some changes and run the tests:
.. prompt:: bash
testament all
Commit the changes. Your commit message should conform to the following
standard::
file/changed: concice and complete statement of the purpose
This is the body of the commit message. The line above is the
summary. The summary should be no more than 72 chars long. The
body can be more freely formatted, but make it look nice. Make
sure to reference any bug reports and other contributors. Make
sure the correct authorship appears.
Use `git rebase`_ if needed to make commit history look good.
.. _git rebase: https://git-rebase.io/
Finally, send a patch to the developer using `git send-email`_:
.. prompt:: bash
git send-email --to=cyber@sysrq.in origin/master
.. _git send-email: https://git-send-email.io/
Code style
----------
Should be `NEP-1`_ for all new contributions, however there are no linters in CI
pipelines yet.
.. _NEP-1: https://nim-lang.org/docs/nep1.html

71
docs/getting-started.rst Normal file
View File

@ -0,0 +1,71 @@
.. SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
..
.. SPDX-License-Identifier: BSD-3-Clause
Getting Started
===============
.. note::
Make sure the project you want to build uses NimScript package file format.
INI format is deprecated and not supported by nimbus.
Setup
-----
.. prompt:: bash
cd my-nim-project
mkdir build && cd build
nimbus ..
This command will create a :file:`ninja.build` file in the build directory.
.. seealso:: :manpage:`nimbus.1` manual page
All the following commands need to be called from the build directory.
Compile
-------
.. prompt:: bash
ninja
This command will build all project binaries, if any. If there are multiple, you
can choose which to build:
.. prompt:: bash
ninja myprog
Run tasks
---------
A ninja target is created for every Nimble task. You can run them on request:
.. prompt:: bash
ninja scss
Run tests
---------
.. prompt:: bash
ninja test
This command will run "test" task (if defined). Otherwise, it will compile and
run all Nim files in the :file:`tests` directory beginning with "t" in their
filename.
This behavior is compatible with Nimble.
Install
-------
.. prompt:: bash
DESTDIR=/tmp/prefix ninja install
This command will install the package (both sources and binaries) into
:file:`/tmp/prefix`.

47
docs/index.rst Normal file
View File

@ -0,0 +1,47 @@
.. SPDX-FileCopyrightText: 2022-2024 Anna <cyber@sysrq.in>
..
.. SPDX-License-Identifier: BSD-3-Clause
Introduction
============
nimbus is a build system for `Nim`_. It is compatible with the `Nimble`_ package
format, so you can use it to build and install packages from the `Nimble
Directory`_ and other sources.
.. _Nim: https://nim-lang.org/
.. _Nimble: https://nimble.directory/
.. _Nimble Directory: https://nimble.directory/
If you want to learn about how to use nimbus, check out the following resources:
* :doc:`installation`
* :doc:`getting-started`
If you need help, or want to talk to the developers, use our chat rooms:
* IRC: `#nimbus`_ at ``irc.oftc.net``
* Matrix: `#nimbus:sysrq.in`_
.. _#nimbus: https://kiwiirc.com/nextclient/#ircs://irc.oftc.net:+6697/nimbus
.. _#nimbus\:sysrq.in: https://matrix.to/#/#nimbus:sysrq.in
If you find any bugs, please report them on `Bugzilla`_.
.. _Bugzilla: https://bugs.sysrq.in/enter_bug.cgi?product=Software&component=nimbus
Raison d'être
-------------
nimble is a great tool for development but it does not get on well with system
package managers. This project is intended to be used with traditional package
managers (primarly with Gentoo's Portage). But maybe it'll be useful for other
purposes too.
Development status
------------------
This software is considered `completed`__ and stable. No new features are
planned, however there will be releases for bug fixes and compatibility updates.
__ https://drewdevault.com/2021/01/04/A-culture-of-stability-and-reliability.html

53
docs/installation.rst Normal file
View File

@ -0,0 +1,53 @@
.. SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
..
.. SPDX-License-Identifier: BSD-3-Clause
Installation
============
Prerequisites
-------------
The only build dependency is a working Nim compiler.
Runtime dependencies are Nim (needed to run scripts) and either `ninja`_ or
`samu`_.
.. _ninja: https://ninja-build.org/
.. _samu: https://github.com/michaelforney/samurai
Gentoo
------
nimbus is packaged for Gentoo in the GURU ebuild repository.
.. prompt:: bash #
eselect repository enable guru
emaint sync -r guru
emerge dev-nim/nimbus
Other distributions
-------------------
.. image:: https://repology.org/badge/vertical-allrepos/nim:nimbus.svg
:alt: Packaging status on Repology
:target: https://repology.org/project/nim:nimbus/versions
Manual installation
-------------------
Using Nimble:
.. prompt:: bash
nimble install https://git.sysrq.in/nimbus
Using Nim (expert):
.. prompt:: bash
git clone https://git.sysrq.in/nimbus
cd nimbus
nim c src/nimbus
nim c src/txt2deps

38
docs/make.bat Normal file
View File

@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: CC0-1.0
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

7
docs/requirements.txt Normal file
View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
insipid-sphinx-theme
sphinx-notfound-page
sphinx-prompt
sphinx-sitemap

29
docs/toc.rst Normal file
View File

@ -0,0 +1,29 @@
.. SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
..
.. SPDX-License-Identifier: BSD-3-Clause
Table of Contents
=================
.. toctree::
:caption: Home
index
.. toctree::
:caption: Documentation
installation
getting-started
contributing
.. toctree::
:caption: External Links
Version History <https://git.sysrq.in/nimbus/plain/ChangeLog>
Git Repository <https://git.sysrq.in/nimbus/>
Indices and tables
==================
* :ref:`search`

View File

@ -9,9 +9,11 @@
.Nd a Nim build system
.Sh SYNOPSIS
.Nm
.Op Fl Fl debug
.Op Fl Fl binDir : Ns Ar path
.Op Fl Fl nimbleDir : Ns Ar path
.Op Fl Fl nim : Ns Ar path
.Op Fl Fl nimcache : Ns Ar path
.Op Fl Fl url : Ns Ar url
.Op nim opts...
.Ar sourceDir
@ -41,12 +43,19 @@ does not support building inside the source directory and attempting to do that
.It Fl Fl binDir : Ns Ar path
Set the executable directory, where project's binaries will be installed.
.
.It Fl Fl debug
Show debugging information.
.
.It Fl Fl nimbleDir : Ns Ar path
Set the Nimble directory, where project's sources will be installed.
.
.It Fl Fl nim : Ns Ar path
Set the Nim executable.
.
.It Fl Fl nimcache : Ns Ar path
Set the Nim cache base directory.
Caches for individual targets will be created there.
.
.It Fl Fl url : Ns Ar url
If this options is set,
.Nm
@ -59,6 +68,43 @@ is unable to find them unless such metadata file exists.
.El
.Pp
All unrecognized flags are passed to the Nim compiler.
.
.Ss NimScript tasks
.Nm
will create a ninja target for each task defined in the
.Pa .nimble
file.
.
.Ss Running tests
If no tasks named
.Qq test
exist,
.Nm
generates a tester script that can be invoked via
.Ql ninja test .
It will compile and run all Nim files in the
.Pa tests
directory beginning with
.Qq t
in their filename.
.Pp
This behavior is compatible with nimble.
.
.Ss Installing
.Nm
generates an installer script that can be invoked via
.Ql ninja install .
It installs both sources and binaries
.Pq if any .
.Pp
If any of the
.Va installDirs , installFiles , installExt
variables are present in the
.Pa .nimble
file,
.Nm
operates in the whitelist mode.
Please refer the to the nimble documentation for more information.
.Sh ENVIRONMENT
.Bl -tag -width DESTDIR
.It Ev DESTDIR
@ -75,6 +121,10 @@ Build file for a ninja-compatible build system.
Script for installing packages.
.It Pa nimblemeta.json
Metadata file that contains package URL.
.It Pa querytool.nims
Script for extracting metadata from
.Pa .nimble
files.
.It Pa tester.nims
Script for running Nimble-style tests.
.El
@ -90,6 +140,7 @@ ninja
sudo ninja install
.Ed
.Sh SEE ALSO
.Xr txt2deps 1
.Bl -bullet -width 1n
.It
.Lk https://nim-lang.org/docs/nimc.html "Nim compiler user guide"

47
man/txt2deps.1 Normal file
View File

@ -0,0 +1,47 @@
.\" SPDX-FileType: DOCUMENTATION
.\" SPDX-FileCopyrightText: 2023 Anna <cyber@sysrq.in>
.\" SPDX-License-Identifier: BSD-3-Clause
.Dd April 25, 2023
.Dt TXT2DEPS 1
.Os
.Sh NAME
.Nm txt2deps
.Nd convert plain list of files to GCC-style depfiles
.Sh SYNOPSIS
.Nm
.Fl T : Ns Ar path
.Op Fl i : Ns Ar path
.Op Fl o : Ns Ar path
.Sh DESCRIPTION
The
.Nm
utility takes a file with newline-separated list of filenames as input and outputs one
.Xr make 1
rule containing the target file name for that source file, a colon, and the names of all the included files.
.Pp
The arguments are as follows:
.Bl -tag -width Ds
.It Fl T : Ns Ar path
Target file name.
.
.It Fl i : Ns Ar path
Input file name.
The default is the standard input.
.
.It Fl o : Ns Ar path
Output file name.
The default is the standard output.
.El
.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Generate a depfile:
.Dl txt2deps -O test < ~/.cache/nim/test/test.deps > test.d
.Sh SEE ALSO
.Xr make 1 ,
.Xr nimbus 1
.Sh AUTHORS
.An -split
.An Anna
.Aq Mt cyber@sysrq.in

View File

@ -1,14 +1,14 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: CC0-1.0
# Package
version = "0.2.4"
version = "1.1.3"
author = "Anna"
description = "A Nim build system."
description = "A packaging-friendly Nim build system"
license = "BSD"
bin = @["nimbus"]
bin = @["nimbus", "txt2deps"]
srcDir = "src"
installExt = @["nim"]
@ -20,3 +20,7 @@ requires "nim >= 0.13.0"
task test, "Test nimbus with Testament":
exec("testament all")
task clean, "Clean test files":
rmFile("outputGotten.txt")
rmDir("testresults")

View File

@ -1,4 +1,5 @@
# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: CC0-1.0
--threads:on
--gc:orc
--threads:off

View File

@ -0,0 +1,85 @@
# SPDX-FileCopyrightText: 2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
## This module is used to generate a NimScript file that, when executed, tells
## Nim to generate a build script in a custom JSON format.
import std/strutils
import common, options
proc writeBuilderScript*(f: File, options: Options) =
f.write("""#!/usr/bin/env nim e
import std/[os, parseopt, strformat, strutils]
mode = Verbose
const
nimBin = $1.quoteShell
nimFlags = $2
nimCacheBaseDir = $3
type
Options = object
genScript: bool
target: string
targetName: string
inFile: string
outFile: string
paths: seq[string]
proc genScript(options: Options) =
var paths = ""
if options.paths.len != 0:
paths = "-p:" & options.paths.join(" -p:")
let nimCache = nimCacheBaseDir / options.targetName
exec fmt"{nimBin} {nimFlags} c --genScript:on --nimcache:{nimCache.quoteShell}" &
fmt" -o:{options.outFile.quoteShell} {paths} {options.inFile.quoteShell}"
let txt2deps = findExe("txt2deps")
if txt2deps.len != 0:
let nimDepsFile = nimCache / options.targetName.addFileExt("deps")
let gccDepsFile = options.target.addFileExt("d")
exec fmt"{txt2deps} -T:{options.target.quoteShell}" &
fmt" -i:{nimDepsFile.quoteShell} -o:{gccDepsFile.quoteShell}"
proc execScript(options: Options) =
let nimCache = nimCacheBaseDir / options.targetName
withDir nimCache:
exec fmt"{nimBin} {nimFlags} jsonscript --nimcache:{nimCache.quoteShell}" &
fmt" -o:{options.outFile.quoteShell} {options.inFile.quoteShell}"
proc parseCmdLine(): Options =
result.genScript = true
for kind, key, val in getOpt():
case kind
of cmdArgument:
result.inFile = key
of cmdLongOption, cmdShortOption:
case key.normalize()
of "t":
# full path!
result.target = val
result.targetName = val.extractFilename
result.outFile = val.addFileExt(ExeExt)
of "p":
result.paths.add(val)
of "genscript":
result.genScript = true
of "jsonscript":
result.genScript = false
else:
discard
of cmdEnd:
discard
let opts = parseCmdLine()
if opts.genScript:
genScript(opts)
else:
execScript(opts)
""" % [options.getNimBin().tripleQuoted,
options.getNimFlags().tripleQuoted,
options.getNimCacheBaseDir().tripleQuoted])

View File

@ -1,10 +1,11 @@
# SPDX-FileCopyrightText: Copyright (C) Dominik Picheta. All rights reserved.
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import strutils
import std/strutils
const
nimbusVersion* = "0.2.4"
nimbusVersion* = "1.1.3"
defaultBinDir* = "/usr/local/bin"
defaultNimbleDir* = "/opt/nimble"
@ -13,8 +14,25 @@ const
packageMetadataFileName* = "nimblemeta.json"
nimCacheDirName* = "nimcache"
builderFileName* = "builder.nims"
installerFileName* = "installer.nims"
testerFileName* = "tester.nims"
queryToolFileName* = "querytool.nims"
proc tripleQuoted*(s: string): string =
nimbleVariables* = [
"packageName",
"version",
"requiresData",
"bin",
"skipDirs",
"skipFiles",
"skipExt",
"installDirs",
"installFiles",
"installExt",
"srcDir"
]
func tripleQuoted*(s: string): string =
## Applies """triple quotes""" to a string.
return '"'.repeat(3) & s & '"'.repeat(3)

View File

@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import logging, os, osproc, parseutils, sequtils, strformat, strutils
import std/[logging, os, osproc, parseutils, sequtils, strformat, strutils]
import options, packagemetadata, version
@ -15,17 +15,18 @@ type
UnsatisfiedDependencyError* = object of CatchableError
proc `<`(pkg: Package, pkg2: Package): bool =
func `<`(pkg: Package, pkg2: Package): bool =
return pkg.version < pkg2.version
proc unsatisfiedDependencyError*(msg: string): ref UnsatisfiedDependencyError =
func unsatisfiedDependencyError*(msg: string): ref UnsatisfiedDependencyError =
result = newException(UnsatisfiedDependencyError, msg)
proc unsupportedPkgWarning(dirName: string) =
warn("Skipped unsupported package: " & dirName)
proc initPkgList(options: Options): seq[Package] =
## Scan the Nimble directory for packages.
proc unsupportedPkgWarning(dirName: string) =
warn("[initPkgList] Skipped unsupported package: " & dirName)
for kind, path in walkDir(options.getPkgsDir):
if kind in {pcDir, pcLinkToDir}:
let dirName = path.lastPathPart
@ -55,7 +56,7 @@ proc getNimVersion*(options: Options): Version =
proc getPath*(depPkg: PkgTuple, options: Options): string =
## Return a path for using with the `--path` Nim compiler option.
var pkgList {.global.}: seq[Package] = @[]
var pkgList {.threadvar.}: seq[Package]
once: pkgList = initPkgList(options)
echo "-- Checking for " & depPkg.name
@ -92,8 +93,8 @@ proc parseRequires*(req: string): PkgTuple =
quit("Unable to parse dependency version range: " &
getCurrentExceptionMsg())
proc `$`*(pkg: Package): string =
func `$`*(pkg: Package): string =
return pkg.name & "@" & $pkg.version
proc `$`*(dep: PkgTuple): string =
func `$`*(dep: PkgTuple): string =
return dep.name & "@" & $dep.ver

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import os, strformat
import std/[os, strformat]
import common, options, packageinfo

View File

@ -1,33 +1,40 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import json, os, osproc, sequtils, strformat, strutils
import std/[json, os, osproc, sequtils, strformat, strutils]
import options
import common, options
proc getSeq*(node: JsonNode): seq[string] =
## Retrieves the `seq[string]` value of a `JArray JsonNode`.
return node.to(seq[string])
proc toJsonString*(nimbleFile: string, options: Options): string =
## Parse standard NimScript variables using a helper tool.
let queryToolFile = options.getBuildDir() / queryToolFileName
if not fileExists(queryToolFile):
quit(fmt"{queryToolFileName} does not exist")
proc query(nimbleFile, variable: string, options: Options): string =
## Return a NimScript variable as a JSON object.
let cmd = (
"$# $# --eval:'import json; include \"$#\"; echo %$#'" % [
"$# $# --eval:'include \"$#\"; include \"$#\"'" % [
getNimBin(options).quoteShell,
"--hints:off --verbosity:0",
nimbleFile,
variable
queryToolFile
]
).strip()
var exitCode: int
(result, exitCode) = execCmdEx(cmd)
if exitCode != QuitSuccess:
quit(fmt"Failed to get the value of `{variable}` from {nimbleFile}")
proc queryString*(nimbleFile, variable: string, options: Options): string =
result = nimbleFile.query(variable, options).parseJson().getStr()
proc queryArray*(nimbleFile, variable: string, options: Options): seq[string] =
result = nimbleFile.query(variable, options).parseJson().to(seq[string])
stderr.write(&"Failed to parse {nimbleFile}\n")
stderr.write(result)
quit(QuitFailure)
proc getTasks*(nimsFile: string, options: Options): seq[string] =
## Parse NimScript tasks from `nim help` output.
let cmd = (
"$# $# help $#" % [
getNimBin(options).quoteShell,

View File

@ -6,13 +6,13 @@
## A module for generating .ninja files.
## RTFM: https://ninja-build.org/manual.html
import sequtils, strformat, strtabs, strutils
import std/[sequtils, strformat, strtabs, strutils]
proc newline*(f: File) =
f.write('\n')
proc comment*(f: File, text: string) =
f.write("# " & text & '\n')
f.write(&"# {text}\n")
proc line(f: File, text: string, indent = 0) =
## Write indented 'text', followed by a newline.
@ -20,19 +20,22 @@ proc line(f: File, text: string, indent = 0) =
proc variable*(f: File, key, value: string, indent = 0) =
if key.len != 0 and value.len != 0:
f.line(&"{key} = {value}", indent)
f.line(fmt"{key} = {value}", indent)
proc pool*(f: File, name, depth: string) =
if name.len != 0 and depth.len != 0:
f.line(&"pool {name}")
f.line(fmt"pool {name}")
f.variable("depth", depth, indent = 1)
proc rule*(f: File, name, command: string; description, depfile, deps, pool,
rspfile, rspfileContent = ""; generator, restat = false) =
proc rule*(
f: File, name, command: string;
description, depfile, deps, pool, rspfile, rspfileContent = "";
generator, restat = false
) =
if name.len == 0 or command.len == 0:
return
f.line(&"rule {name}")
f.line(fmt"rule {name}")
f.variable("command", command, indent = 1)
if description.len != 0:
f.variable("description", description, indent = 1)
@ -51,13 +54,11 @@ proc rule*(f: File, name, command: string; description, depfile, deps, pool,
if restat:
f.variable("restat", "1", indent = 1)
proc escapePaths(paths: var openArray[string]) =
for i in 0..high(paths):
paths[i] = paths[i].replace("$", "$$").replace(" ", "$ ").replace(":", "$:")
proc build*(f: File, outputs: openArray[string], rule: string; inputs, implicit,
orderOnly, implicitOutputs: openArray[string] = [];
variables: StringTableRef = nil; pool, dyndep = "") =
proc build*(
f: File, outputs: openArray[string], rule: string;
inputs, implicit, orderOnly, implicitOutputs: openArray[string] = [];
variables: StringTableRef = nil; pool, dyndep = ""
) =
# note: filterIt converts openArray[string] to seq[string]
var outputs = outputs.filterIt(it != "")
if outputs.len == 0 or rule.len == 0:
@ -68,29 +69,23 @@ proc build*(f: File, outputs: openArray[string], rule: string; inputs, implicit,
var orderOnly = orderOnly.filterIt(it.len != 0)
var implicitOutputs = implicitOutputs.filterIt(it.len != 0)
escapePaths outputs
escapePaths inputs
if implicit.len != 0:
escapePaths implicit
inputs.add("|")
inputs.add(implicit)
if orderOnly.len != 0:
escapePaths orderOnly
inputs.add("||")
inputs.add(orderOnly)
if implicitOutputs.len != 0:
escapePaths implicitOutputs
outputs.add("|")
outputs.add(implicitOutputs)
let outputsStr = join(outputs, " ")
let inputsStr = join(@[rule] & inputs, " ")
f.line(&"build {outputsStr}: {inputsStr}")
f.line(fmt"build {outputsStr}: {inputsStr}")
if pool.len != 0:
f.line(&"pool = {pool}", indent = 1)
f.line(fmt"pool = {pool}", indent = 1)
if dyndep.len != 0:
f.line(&"dyndep = {dyndep}", indent = 1)
f.line(fmt"dyndep = {dyndep}", indent = 1)
if variables != nil:
for key, val in variables.pairs:
@ -98,21 +93,27 @@ proc build*(f: File, outputs: openArray[string], rule: string; inputs, implicit,
proc `include`*(f: File, path: string) =
if path.len != 0:
f.line(&"include {path}")
f.line(fmt"include {path}")
proc subninja*(f: File, path: string) =
if path.len != 0:
f.line(&"subninja {path}")
f.line(fmt"subninja {path}")
proc default*(f: File, paths: openArray[string]) =
var paths = paths.filterIt(it.len != 0)
if paths.len != 0:
f.line("default " & paths.join(" "))
proc default*(f: File, targets: openArray[string]) =
var targets = targets.filterIt(it.len != 0)
if targets.len != 0:
f.line("default " & targets.join(" "))
proc escape*(s: string): string =
func escape*(s: string, body = false): string =
## Escape a string such that it can be embedded into a Ninja file without
## further interpretation.
assert not s.contains("\n"), "Ninja syntax does not allow newlines"
# We only have one special metacharacter: "$".
return s.replace("$", "$$")
if body:
return s.replace("$", "$$")
else:
return s.multiReplace(
("$", "$$"),
(" ", "$ "),
(":", "$:")
)

View File

@ -1,56 +1,73 @@
# SPDX-FileCopyrightText: Copyright (C) Dominik Picheta. All rights reserved.
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import logging, os, parseopt, strutils
import std/[logging, os, parseopt, strformat, strutils]
import common
type
Options* = object
showHelp*: bool
debug*: bool
nimbleDir*: string
binDir*: string
nim*: string # Nim compiler location
url*: string
url*: string
sourceDir*: string
buildDir*: string
logger*: ConsoleLogger
nimCacheBaseDir*: string
passNimFlags*: seq[string]
cmdLine*: seq[string] # only flags, not arguments
const
help* = """
Usage: nimbus [-h] [--nimbleDir:path] [--binDir:path] [--nim:path] [--url:url]
[nim opts...] sourceDir [buildDir]
help* = fmt"""
Usage: nimbus [-h] [--debug] [--nimbleDir:path] [--binDir:path] [--nim:path]
[--nimcache:path] [--url:url] [nim opts...] sourceDir [buildDir]
positional arguments:
sourceDir
buildDir
optional arguments:
-h, --help show this help message and exit
--nimbleDir:path Nimble directory (default: $1).
--binDir:path Executable directory (default: $2).
-h, --help Show this help message and exit.
--debug Show debugging information.
--nimbleDir:path Nimble directory (default: {defaultNimbleDir}).
--binDir:path Executable directory (default: {defaultBinDir}).
--nim:path Nim compiler (default: nim).
--nimcache:path Base directory for Nim cache (default: {nimCacheDirName}).
--url:url Package URL.
Unrecognized flags are passed to the Nim compiler.
""" % [defaultNimbleDir, defaultBinDir]
""".strip()
proc writeHelp*() =
echo(help)
quit(QuitSuccess)
proc initLogger*(options: Options) =
if getHandlers().len != 0:
return
addHandler(options.logger)
if options.debug:
setLogFilter(lvlDebug)
else:
setLogFilter(lvlNotice)
proc setLogger*(options: var Options) =
options.logger = newConsoleLogger()
addHandler(options.logger)
options.initLogger()
proc getBuildDir*(options: Options): string =
func getBuildDir*(options: Options): string =
return options.buildDir
proc getNimCache*(options: Options): string =
return options.getBuildDir() / nimCacheDirName
func getNimCacheBaseDir*(options: Options): string =
if options.nimCacheBaseDir.len == 0:
return options.getBuildDir() / nimCacheDirName
else:
return options.nimCacheBaseDir
proc setBuildDir*(options: var Options) =
if options.buildDir.len != 0:
@ -59,7 +76,7 @@ proc setBuildDir*(options: var Options) =
else:
options.buildDir = getCurrentDir()
proc getSourceDir*(options: Options): string =
func getSourceDir*(options: Options): string =
return options.sourceDir
proc setSourceDir*(options: var Options) =
@ -67,11 +84,11 @@ proc setSourceDir*(options: var Options) =
if not dirExists(options.sourceDir):
quit("Source directory $1 does not exist" % options.sourceDir)
proc getNimbleDir*(options: Options): string =
func getNimbleDir*(options: Options): string =
## Get the Nimble directory.
return options.nimbleDir
proc getPkgsDir*(options: Options): string =
func getPkgsDir*(options: Options): string =
## Get the packages directory inside the Nimble directory.
options.getNimbleDir() / nimblePackagesDirName
@ -82,7 +99,7 @@ proc setNimbleDir*(options: var Options) =
else:
options.nimbleDir = defaultNimbleDir
proc getBinDir*(options: Options): string =
func getBinDir*(options: Options): string =
## Get the executable directory.
return options.binDir
@ -120,13 +137,13 @@ proc setNimBin*(options: var Options) =
# Nim not found in PATH
quit("Unable to find `nim` binary - add to $PATH or use `--nim`")
proc getNimBin*(options: Options): string =
func getNimBin*(options: Options): string =
return options.nim
proc getNimFlags*(options: Options): string =
func getNimFlags*(options: Options): string =
return options.passNimFlags.join(" ")
proc getFlagString(kind: CmdLineKind, flag, val: string): string =
func getFlagString(kind: CmdLineKind, flag, val: string): string =
## Make a flag string from components. The result is quoted.
let prefix =
case kind
@ -139,21 +156,24 @@ proc getFlagString(kind: CmdLineKind, flag, val: string): string =
result = prefix & flag & ":" & val
return result.quoteShell
proc parseFlag(flag, val: string, result: var Options, kind = cmdLongOption) =
func parseFlag(flag, val: string, result: var Options, kind = cmdLongOption) =
let f = flag.normalize()
let flagString = getFlagString(kind, flag, val)
case f
of "help", "h": result.showHelp = true
of "debug": result.debug = true
of "usedepfile": discard
of "nimbledir": result.nimbleDir = val
of "bindir": result.binDir = val
of "nim": result.nim = val
of "url": result.url = val
of "nimcache": result.nimCacheBaseDir = val
else: result.passNimFlags.add(flagString)
result.cmdline.add(flagString)
proc parseArgument(key: string, argc: var int, result: var Options) =
func parseArgument(key: string, argc: var int, result: var Options) =
inc argc
case argc
of 1: result.sourceDir = key
@ -161,6 +181,10 @@ proc parseArgument(key: string, argc: var int, result: var Options) =
else: discard
proc parseCmdLine*(): Options =
# set default values here
result.debug = false
result.showHelp = false
var argc = 0
for kind, key, val in getOpt():
case kind
@ -173,7 +197,7 @@ proc parseCmdLine*(): Options =
if argc notin {1..2}:
result.showHelp = true
proc getCmdLine*(options: Options): string =
func getCmdLine*(options: Options): string =
var cmdLine = options.cmdLine
cmdLine.add(options.getSourceDir().quoteShell)
cmdLine.add(options.getBuildDir().quoteShell)

View File

@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import logging, os, sequtils, threadpool
import std/[json, logging, os, sequtils]
import nimbleexecutor, options
@ -25,12 +25,6 @@ type
kind: PathComponent
path: string
proc getPackageName*(nimbleFile: string, options: Options): string =
let packageName = nimbleFile.queryString("packageName", options)
if packageName.len != 0:
return packageName
return splitFile(nimbleFile).name
proc findNimbleFile*(dir: string): string =
var hits = 0
for kind, path in walkDir(dir):
@ -46,43 +40,35 @@ proc findNimbleFile*(dir: string): string =
"specified directory: " & dir)
proc initPackageInfo*(options: Options): PackageInfo =
## Fill a new PackageInfo object using values from the Nimble file.
let nimbleFile = options.getSourceDir().findNimbleFile()
let name = spawn nimbleFile.getPackageName(options)
let version = spawn nimbleFile.queryString("version", options)
let requires = spawn nimbleFile.queryArray("requiresData", options)
let bin = spawn nimbleFile.queryArray("bin", options)
let skipDirs = spawn nimbleFile.queryArray("skipDirs", options)
let skipFiles = spawn nimbleFile.queryArray("skipFiles", options)
let skipExt = spawn nimbleFile.queryArray("skipExt", options)
let installDirs = spawn nimbleFile.queryArray("installDirs", options)
let installFiles = spawn nimbleFile.queryArray("installFiles", options)
let installExt = spawn nimbleFile.queryArray("installExt", options)
let srcDir = spawn nimbleFile.queryString("srcDir", options)
sync()
result.nimbleFile = nimbleFile
result.name = ^name
result.version = ^version
result.requires = ^requires
result.bin = ^bin
result.skipDirs = ^skipDirs
result.skipFiles = ^skipFiles
result.skipExt = ^skipExt
result.installDirs = ^installDirs
result.installFiles = ^installFiles
result.installExt = ^installExt
result.srcDir = ^srcDir
proc getSourceDir*(pkgInfo: PackageInfo, options: Options): string =
let variables = nimbleFile.toJsonString(options).parseJson()
result.name = variables["packageName"].getStr()
result.version = variables["version"].getStr()
result.requires = variables["requiresData"].getSeq()
result.bin = variables["bin"].getSeq()
result.skipDirs = variables["skipDirs"].getSeq()
result.skipFiles = variables["skipFiles"].getSeq()
result.skipExt = variables["skipExt"].getSeq()
result.installDirs = variables["installDirs"].getSeq()
result.installFiles = variables["installFiles"].getSeq()
result.installExt = variables["installExt"].getSeq()
result.srcDir = variables["srcDir"].getStr()
if result.name.len == 0:
result.name = splitFile(nimbleFile).name
func getSourceDir*(pkgInfo: PackageInfo, options: Options): string =
## Returns the directory containing the package source files.
if pkgInfo.srcDir.len != 0:
return options.getSourceDir() / pkgInfo.srcDir
else:
return options.getSourceDir()
proc checkInstallFile(pkgInfo: PackageInfo, sourceDir, file: string): bool =
func checkInstallFile(pkgInfo: PackageInfo, sourceDir, file: string): bool =
## Checks whether ``file`` should be installed.
## ``True`` means file should be skipped.
if file == pkgInfo.nimbleFile:
@ -99,7 +85,7 @@ proc checkInstallFile(pkgInfo: PackageInfo, sourceDir, file: string): bool =
if splitFile(file).name[0] == '.': return true
proc checkInstallDir(pkgInfo: PackageInfo, sourceDir, dir: string): bool =
func checkInstallDir(pkgInfo: PackageInfo, sourceDir, dir: string): bool =
## Determines whether ``dir`` should be installed.
## ``True`` means dir should be skipped.
for ignoreDir in pkgInfo.skipDirs:

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import json, os, streams
import std/[json, os, streams]
import common

View File

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/strformat
import common
proc writeQueryToolScript*(f: File) =
f.write("""#!/usr/bin/env nim e
import json
echo %{
""")
for variable in nimbleVariables:
f.write(&" \"{variable}\": %{variable},\n")
f.write("}\n")

View File

@ -1,26 +1,28 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import os, strutils
import std/strutils
import common, options
proc writeTesterScript*(f: File, options: Options) =
f.write("""#!/usr/bin/env nim e
import os, strformat, strutils
import std/[os, strformat, strutils]
const
nimBin = $1
nimBin = $1.quoteShell
nimFlags = $2
nimCacheDir = $3
nimCacheBaseDir = $3
withDir($4):
for test in listFiles("tests"):
if test.startsWith("tests/t") and test.endsWith(".nim"):
let nimCacheDir = nimCacheBaseDir / test.changeFileExt("")
echo "-- Running test ", test, "..."
exec(fmt"{nimBin} --hints:off {nimFlags} r --nimcache:{nimCacheDir} {test.quoteShell}")
""" % [options.getNimBin().quoteShell.tripleQuoted,
exec fmt"{nimBin} --hint:all:off --warning:all:off {nimFlags} r" &
fmt" --nimcache:{nimCacheDir.quoteShell} {test.quoteShell}"
""" % [options.getNimBin().tripleQuoted,
options.getNimFlags().tripleQuoted,
options.getNimCache().quoteShell.tripleQuoted,
options.getNimCacheBaseDir().tripleQuoted,
options.getSourceDir().tripleQuoted])

View File

@ -3,7 +3,7 @@
## Module for handling versions and version ranges such as ``>= 1.0 & <= 1.5``
import parseutils, strutils
import std/[parseutils, strutils]
type
Version* {.requiresInit.} = object
@ -35,17 +35,17 @@ type
const
notSetVersion* = Version(version: "-1")
proc parseVersionError*(msg: string): ref ParseVersionError =
func parseVersionError*(msg: string): ref ParseVersionError =
result = newException(ParseVersionError, msg)
template `$`*(ver: Version): string = ver.version
func `$`*(ver: Version): string = ver.version
proc newVersion*(ver: string): Version =
func newVersion*(ver: string): Version =
if ver.len != 0 and ver[0] notin {'\0'} + Digits:
raise parseVersionError("Wrong version: " & ver)
return Version(version: ver)
proc `<`*(ver: Version, ver2: Version): bool =
func `<`*(ver: Version, ver2: Version): bool =
# Handling for normal versions such as "0.1.0" or "1.0".
var sVer = ver.version.split('.')
var sVer2 = ver2.version.split('.')
@ -63,7 +63,7 @@ proc `<`*(ver: Version, ver2: Version): bool =
else:
return false
proc `==`*(ver: Version, ver2: Version): bool =
func `==`*(ver: Version, ver2: Version): bool =
var sVer = ver.version.split('.')
var sVer2 = ver2.version.split('.')
for i in 0..max(sVer.len, sVer2.len)-1:
@ -78,10 +78,10 @@ proc `==`*(ver: Version, ver2: Version): bool =
else:
return false
proc `<=`*(ver: Version, ver2: Version): bool =
func `<=`*(ver: Version, ver2: Version): bool =
return (ver == ver2) or (ver < ver2)
proc `==`*(range1: VersionRange, range2: VersionRange): bool =
func `==`*(range1: VersionRange, range2: VersionRange): bool =
if range1.kind != range2.kind : return false
result = case range1.kind
of verLater, verEarlier, verEqLater, verEqEarlier, verEq:
@ -90,7 +90,7 @@ proc `==`*(range1: VersionRange, range2: VersionRange): bool =
range1.verILeft == range2.verILeft and range1.verIRight == range2.verIRight
of verAny: true
proc withinRange*(ver: Version, ran: VersionRange): bool =
func withinRange*(ver: Version, ran: VersionRange): bool =
case ran.kind
of verLater:
return ver > ran.ver
@ -107,10 +107,10 @@ proc withinRange*(ver: Version, ran: VersionRange): bool =
of verAny:
return true
proc contains*(ran: VersionRange, ver: Version): bool =
func contains*(ran: VersionRange, ver: Version): bool =
return withinRange(ver, ran)
proc getNextIncompatibleVersion(version: Version, semver: bool): Version =
func getNextIncompatibleVersion(version: Version, semver: bool): Version =
## try to get next higher version to exclude according to semver semantic
var numbers = version.version.split('.')
let originalNumberLen = numbers.len
@ -141,7 +141,7 @@ proc getNextIncompatibleVersion(version: Version, semver: bool): Version =
inc(zeroPosition)
result = newVersion(numbers.join("."))
proc makeRange(version: Version, op: string): VersionRange =
func makeRange(version: Version, op: string): VersionRange =
if version == notSetVersion:
raise parseVersionError("A version needs to accompany the operator.")
@ -171,7 +171,7 @@ proc makeRange(version: Version, op: string): VersionRange =
else:
raise parseVersionError("Invalid operator: " & op)
proc parseVersionRange*(s: string): VersionRange =
func parseVersionRange*(s: string): VersionRange =
# >= 1.5 & <= 1.8
if s.len == 0:
result = VersionRange(kind: verAny)
@ -218,7 +218,7 @@ proc parseVersionRange*(s: string): VersionRange =
inc(i)
result = makeRange(newVersion(version), op)
proc `$`*(verRange: VersionRange): string =
func `$`*(verRange: VersionRange): string =
case verRange.kind
of verLater:
result = "> "

View File

@ -1,12 +1,24 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import os, sequtils, strtabs, strutils
import std/strutils except escape
import std/[logging, os, sequtils, strtabs, strformat]
import nimbs/common, nimbs/dependencyresolver, nimbs/installerscript,
nimbs/ninjasyntax, nimbs/nimbleexecutor, nimbs/options,
nimbs/packageinfo, nimbs/packagemetadata, nimbs/testerscript,
nimbs/version
import nimbs/[common, options]
import nimbs/[ninjasyntax]
import nimbs/[
dependencyresolver,
nimbleexecutor,
packageinfo,
packagemetadata,
version
]
import nimbs/[
builderscript,
installerscript,
querytoolscript,
testerscript
]
proc processDependencies(requires: seq[string], options: Options): seq[string] =
## Checks package dependencies and returns list of paths for the Nim compiler,
@ -18,28 +30,48 @@ proc processDependencies(requires: seq[string], options: Options): seq[string] =
let nimVer = getNimVersion(options)
if not withinRange(nimVer, dep.ver):
raise unsatisfiedDependencyError("Unsatisfied Nim dependency")
debug("Found suitable Nim version")
else:
result.add(dep.getPath(options).quoteShell)
proc application(ninja: File, input, output: string, paths: seq[string]) =
var vars = newStringTable()
if paths.len != 0:
vars["paths"] = "-p:" & paths.join(" -p:")
proc application(ninja: File, input, targetName: string;
paths: seq[string], options: Options) =
debug(fmt"[build.ninja] Generating target for application '{targetName}'")
ninja.build([output],
rule = "nimc",
inputs = [input],
implicit = ["PHONY"], # FIXME: add depfile support to the Nim compiler
var vars = newStringTable()
vars["targetname"] = targetName
vars["target"] = "$builddir" / targetName.escape(body = true)
vars["sourcefile"] = input.escape(body = true)
vars["nimcache"] = escape(options.getNimCacheBaseDir() / targetName,
body = true)
if paths.len != 0:
vars["paths"] = escape("-p:" & paths.join(" -p:"), body = true)
let jsonScript = "$nimcache" / targetName.addFileExt("json").escape
ninja.build([jsonScript],
rule = "genscript",
inputs = [input.escape, "$builder"],
variables = vars
)
ninja.newline()
ninja.build([vars["target"].addFileExt(ExeExt)],
rule = "jsonscript",
inputs = [input.escape, "$builder"],
implicit = [jsonScript],
variables = vars
)
ninja.newline()
proc task(ninja: File, nimsFile, taskName: string) =
debug(fmt"[build.ninja] Generating target for task '{taskName}'")
var vars = newStringTable()
vars["taskname"] = taskName
ninja.build([taskName],
ninja.build([taskName.escape],
rule = "nimbletask",
inputs = [nimsFile],
inputs = [nimsFile.escape],
implicit = ["PHONY"],
variables = vars
)
@ -56,6 +88,12 @@ proc setup(options: Options) =
if options.getSourceDir() == options.getBuildDir():
quit("In-source builds are not allowed")
debug("Writing query tool script")
let queryTool = open(options.getBuildDir() / queryToolFileName, fmWrite)
queryTool.writeQueryToolScript()
queryTool.close()
debug("Populating package info")
let pkgInfo = initPackageInfo(options)
echo "Project name: " & pkgInfo.name
echo "Project version: " & pkgInfo.version
@ -69,7 +107,9 @@ proc setup(options: Options) =
let nimsFile =
nimbusPriv / splitFile(pkgInfo.nimbleFile).name.changeFileExt("nims")
debug("Copying nimble file to nimbus-private")
copyFile(pkgInfo.nimbleFile, nimsFile)
debug("Querying tasks")
let tasks = nimsFile.getTasks(options)
if options.url.len != 0:
@ -79,10 +119,11 @@ proc setup(options: Options) =
nimblemeta.writeMetaData(options.url)
nimblemeta.close()
echo "-- Generating installer script"
let installer = open(options.getBuildDir() / installerFileName, fmWrite)
installer.writeInstallerScript(pkgInfo, options)
installer.close()
if pkgInfo.bin.len != 0:
echo "-- Generating builder script"
let builder = open(options.getBuildDir() / builderFileName, fmWrite)
builder.writeBuilderScript(options)
builder.close()
if "test" notin tasks and dirExists(options.getSourceDir() / "tests"):
echo "-- Generating tester script"
@ -91,21 +132,29 @@ proc setup(options: Options) =
tester.close()
nimbleTests = true
echo "-- Generating installer script"
let installer = open(options.getBuildDir() / installerFileName, fmWrite)
installer.writeInstallerScript(pkgInfo, options)
installer.close()
echo "-- Generating build.ninja"
let ninja = open(options.getBuildDir() / "build.ninja", fmWrite)
debug("[build.ninja] Writing comments")
ninja.comment("This file is autogenerated by the nimbus build system.")
ninja.comment("Do not edit by hand.")
ninja.newline()
ninja.variable("nim", options.getNimBin())
ninja.variable("nimbus", getAppFilename())
ninja.variable("nimflags", options.getNimFlags())
ninja.variable("sourcedir", options.getSourceDir())
ninja.variable("nimcache", options.getNimCache())
ninja.variable("cmdline", options.getCmdLine())
debug("[build.ninja] Writing variables")
ninja.variable("sourcedir", options.getSourceDir().escape(body = true))
ninja.variable("builddir", options.getBuildDir().escape(body = true))
ninja.variable("nim", options.getNimBin().escape(body = true))
ninja.variable("nimbus", getAppFilename().escape(body = true))
ninja.variable("cmdline", options.getCmdLine().escape(body = true))
ninja.variable("builder", builderFileName.escape(body = true))
ninja.newline()
debug("[build.ninja] Generating 'REGENERATE_BUILD' rule")
ninja.rule("REGENERATE_BUILD",
command = "$nimbus $cmdline",
description = "Regenerating build files.",
@ -113,27 +162,44 @@ proc setup(options: Options) =
generator = true)
ninja.newline()
debug("[build.ninja] Generating 'nimscript' rule")
ninja.rule("nimscript",
command = "$nim --hints:off e $in",
description = "Executing NimScript file $in",
pool = "console")
ninja.newline()
if pkgInfo.bin.len != 0:
debug("[build.ninja] Generating 'genscript' rule")
ninja.rule("genscript",
command = "$nim --hints:off e $builder" &
" --genscript -T:$target $paths $sourcefile",
description = "Generating build script for Nim application $targetname",
depfile = "$target".addFileExt("d"),
deps = "gcc",
pool = "console")
ninja.newline()
debug("[build.ninja] Generating 'jsonscript' rule")
ninja.rule("jsonscript",
command = "$nim --hints:off e $builder" &
" --jsonscript -T:$target $sourcefile",
description = "Compiling Nim application $targetname",
depfile = "$target".addFileExt("d"),
deps = "gcc",
pool = "console")
ninja.newline()
if tasks.len != 0:
# most tasks are supposed to be run from the project root
debug("[build.ninja] Generating 'nimbletask' rule")
ninja.rule("nimbletask",
command = "cd $sourcedir && $nim --hints:off $taskname $in",
description = "Executing task $taskname",
pool = "console")
ninja.newline()
if pkgInfo.bin.len != 0:
ninja.rule("nimc",
command = "$nim --hints:off $nimflags c --nimcache:$nimcache " &
"-o:$out $paths $in",
description = "Compiling Nim application $out")
ninja.newline()
debug("[build.ninja] Generating 'PHONY' target")
ninja.comment("Phony build target, always out of date")
ninja.build(["PHONY"], rule = "phony")
ninja.newline()
@ -142,38 +208,45 @@ proc setup(options: Options) =
ninja.task(nimsFile, taskName)
ninja.newline()
debug("[build.ninja] Generating 'build.ninja' target")
ninja.build(["build.ninja"],
rule = "REGENERATE_BUILD",
inputs = [pkgInfo.nimbleFile])
inputs = [pkgInfo.nimbleFile.escape])
ninja.newline()
debug("[build.ninja] Generating 'reconfigure' target")
ninja.build(["reconfigure"],
rule = "REGENERATE_BUILD",
implicit = ["PHONY"])
ninja.newline()
for bin in pkgInfo.bin:
let output = bin.lastPathPart.addFileExt(ExeExt)
let input = pkgInfo.getSourceDir(options) / bin.addFileExt("nim")
ninja.application(input, output, depPaths)
ninja.newline()
let targetName = bin.lastPathPart
ninja.application(input, targetName, depPaths, options)
debug("[build.ninja] Generating 'all' target")
ninja.build(["all"],
rule = "phony",
inputs = pkgInfo.bin.mapIt(it.lastPathPart.addFileExt(ExeExt)))
inputs = pkgInfo.bin.mapIt(
"$builddir" / it.lastPathPart.addFileExt(ExeExt).escape
)
)
ninja.default(["all"])
ninja.newline()
if nimbleTests:
debug("[build.ninja] Generating 'test' target")
ninja.build(["test"],
rule = "nimscript",
inputs = [testerFileName],
inputs = [testerFileName.escape(body = true)],
implicit = ["PHONY", "all"])
ninja.newline()
debug("[build.ninja] Generating 'install' target")
ninja.build(["install"],
rule = "nimscript",
inputs = [installerFileName],
inputs = [installerFileName.escape(body = true)],
implicit = ["PHONY", "all"])
ninja.close()

80
src/txt2deps.nim Normal file
View File

@ -0,0 +1,80 @@
# SPDX-FileCopyrightText: 2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/[os, parseopt, strutils]
type
Options = object
invalidArguments: bool
showHelp: bool
target: string
inFilePath: string
outFilePath: string
const help* = """
Usage: txt2deps -T:path [-h] [-i:path] [-o:path]
Converts plain list of files to GCC-style depfile.
arguments:
-h, --help Show this help message and exit.
-T:path Build target.
-i:path Input deps file (default: stdin).
-o:path Output deps file (default: stdout).
""".strip()
proc writeHelp(status: int = QuitSuccess) =
echo(help)
quit(status)
proc parseCmdline(): Options =
# Init the defaults
result.invalidArguments = false
result.showHelp = false
for kind, key, val in getOpt():
case kind
of cmdLongOption, cmdShortOption:
case key.normalize()
of "help", "h": result.showHelp = true
of "t": result.target = val
of "i": result.inFilePath = val
of "o": result.outFilePath = val
else: result.invalidArguments = true
of cmdArgument:
result.invalidArguments = true
of cmdEnd:
discard
if result.target.len == 0:
result.invalidArguments = true
func quoteMake(s: string): string =
return s.multiReplace(
(" ", "\\ "),
("#", "\\#")
)
proc main(options: Options) =
var inFile = stdin
var outFile = stdout
if options.inFilePath.len != 0:
inFile = open(options.inFilePath)
if options.outFilePath.len != 0:
outFile = open(options.outFilePath, fmWrite)
outFile.write(options.target.quoteMake & ": \\" & '\n')
for line in inFile.lines:
if line.len == 0 or not fileExists(line):
continue
outFile.write('\t' & line.quoteMake & " \\" & '\n')
outFile.close()
when isMainModule:
let opt = parseCmdLine()
if opt.showHelp:
writeHelp()
if opt.invalidArguments:
writeHelp(QuitFailure)
main(opt)

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
@ -11,11 +11,11 @@ discard """
'''
"""
import os, unittest
import nimbs/dependencyresolver, nimbs/options, nimbs/version
import std/[os, unittest]
import nimbs/[dependencyresolver, options, version]
const
nimbleDir = "tests" / "dependencyresolver" / "nimbleDir"
nimbleDir = "tests" / "nimble" / "dependencyresolver" / "nimbleDir"
pkgsDir = nimbleDir / "pkgs2"
let

View File

@ -1,14 +1,14 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
joinable: false
"""
import os, unittest
import nimbs/dependencyresolver, nimbs/options, nimbs/version
import std/[os, unittest]
import nimbs/[dependencyresolver, options, version]
const nimbleDir = "tests" / "dependencyresolver" / "notexists"
const nimbleDir = "tests" / "nimble" / "dependencyresolver" / "notexists"
let pkgA: PkgTuple = ("packageA", parseVersionRange(">= 0.1"))
var opts = Options(nimbleDir: nimbleDir)

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
@ -6,17 +6,17 @@ discard """
sortoutput: true
output: '''-- Found packageA, version 0.5.0
-- Checking for packageA
WARN Skipped unsupported package: packageA
WARN Skipped unsupported package: packageA-#abc123
WARN Skipped unsupported package: packageA-abc
WARN [initPkgList] Skipped unsupported package: packageA
WARN [initPkgList] Skipped unsupported package: packageA-#abc123
WARN [initPkgList] Skipped unsupported package: packageA-abc
'''
"""
import os
import nimbs/dependencyresolver, nimbs/options, nimbs/version
import std/os
import nimbs/[dependencyresolver, options, version]
const
nimbleDir = "tests" / "dependencyresolver" / "nimbleDir_unsupported"
nimbleDir = "tests" / "nimble" / "dependencyresolver" / "nimbleDir_unsupported"
pkgsDir = nimbleDir / "pkgs2"
let pkgA: PkgTuple = ("packageA", parseVersionRange(">= 0.1"))

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
@ -9,11 +9,11 @@ discard """
'''
"""
import os, unittest
import nimbs/dependencyresolver, nimbs/options, nimbs/version
import std/[os, unittest]
import nimbs/[dependencyresolver, options, version]
const
nimbleDir = "tests" / "dependencyresolver" / "nimbleDir"
nimbleDir = "tests" / "nimble" / "dependencyresolver" / "nimbleDir"
pkgsDir = nimbleDir / "pkgs2"
let

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import nimbs/dependencyresolver, nimbs/version
import nimbs/[dependencyresolver, version]
assert parseRequires("nim >= 1.0") == ("nim", parseVersionRange(">= 1.0"))
assert parseRequires("packageA") == ("packageA", VersionRange(kind: verAny))

View File

@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/os
import nimbs/[nimbleexecutor, options]
var opts = Options()
opts.setNimBin
const nimbleFile = "tests" / "nimble" / "nimbleexecutor" / "blank.nimble"
assert nimbleFile.getTasks(opts) == @[]

View File

@ -1,13 +1,13 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import os, std/tempfiles
import nimbs/nimbleexecutor, nimbs/options
import std/[os, tempfiles]
import nimbs/[nimbleexecutor, options]
var opts = Options()
opts.setNimBin
const nimbleFile = "tests" / "nimbleexecutor" / "nimble.nimble"
const nimbleFile = "tests" / "nimble" / "nimbleexecutor" / "nimble.nimble"
let nimsFile = genTempPath("nimscript_", ".nims")
copyFile(nimbleFile, nimsFile)

View File

@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
joinable: false
output: '''{"packageName":"","version":"0.14.0","requiresData":["nim >= 0.13.0"],"bin":["nimble"],"skipDirs":[],"skipFiles":[],"skipExt":[],"installDirs":[],"installFiles":[],"installExt":["nim"],"srcDir":"src"}
'''
"""
import std/[os, tempfiles]
import nimbs/[common, nimbleexecutor, options, querytoolscript]
const nimbleFile = "tests" / "nimble" / "nimbleexecutor" / "nimble.nimble"
let tempDir = createTempDir("nimbustest_", "")
let queryTool = open(tempDir / queryToolFileName, fmWrite)
queryTool.writeQueryToolScript()
queryTool.close()
var opts = Options(buildDir: tempDir)
opts.setBuildDir
opts.setNimBin
echo nimbleFile.toJsonString(opts)
removeDir(tempDir)

View File

@ -3,6 +3,6 @@
version = "1.0"
skipDirs = @["test"]
skipDirs = @["_test"]
skipFiles = @["README.md"]
skipExt = @["test"]

View File

@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/os
import nimbs/packageinfo
const dir = "tests" / "nimble" / "packageinfo" / "1nimble"
assert findNimbleFile(dir) == dir / "file.nimble"

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
@ -6,9 +6,9 @@ discard """
outputsub: "Only one .nimble file should be present in"
"""
import os
import std/os
import nimbs/packageinfo
const dir = "tests" / "packageinfo" / "2nimble"
const dir = "tests" / "nimble" / "packageinfo" / "2nimble"
discard findNimbleFile(dir)

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Anna <cyber@sysrq.in>
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
discard """
@ -6,9 +6,9 @@ discard """
outputsub: "Could not find a file with a .nimble extension inside the specified directory:"
"""
import os
import std/os
import nimbs/packageinfo
const dir = "tests" / "packageinfo" / "0nimble"
const dir = "tests" / "nimble" / "packageinfo" / "0nimble"
discard findNimbleFile(dir)

View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/[algorithm, os]
import nimbs/[options, packageinfo]
const sourceDir = "tests" / "nimble" / "packageinfo" / "binary"
let
opts = Options(sourceDir: sourceDir)
pkgInfo = PackageInfo(
nimbleFile: sourceDir / "binary.nimble",
name: "binary",
version: "1.0",
bin: @["tools/main"],
skipFiles: @["README.md"]
)
let files = pkgInfo.getInstallFiles(opts).sorted
assert files == @[
(pcFile, sourceDir / "tools" / "main.nim"),
(pcDir, sourceDir / "tools")
]

View File

@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/[algorithm, os]
import nimbs/[options, packageinfo]
const sourceDir = "tests" / "nimble" / "packageinfo" / "source"
let
opts = Options(sourceDir: sourceDir)
pkgInfo = PackageInfo(
nimbleFile: sourceDir / "source.nimble",
name: "source",
version: "1.0",
skipDirs: @["_test"],
skipFiles: @["README.md"],
skipExt: @["test"]
)
let files = pkgInfo.getInstallFiles(opts).sorted
assert files == @[
(pcFile, sourceDir / "source" / "file1.nim"),
(pcFile, sourceDir / "source" / "file2.nim"),
(pcDir, sourceDir / "source")
]

View File

@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/[algorithm, os]
import nimbs/[options, packageinfo]
const sourceDir = "tests" / "nimble" / "packageinfo" / "source-whitelist"
let
opts = Options(sourceDir: sourceDir)
pkgInfo = PackageInfo(
nimbleFile: sourceDir / "source-whitelist.nimble",
name: "source-whitelist",
version: "1.0",
installExt: @["nim"]
)
let files = pkgInfo.getInstallFiles(opts).sorted
assert files == @[
(pcFile, sourceDir / "file1.nim"),
(pcFile, sourceDir / "file2.nim")
]

View File

@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2022-2023 Anna <cyber@sysrq.in>
# SPDX-License-Identifier: BSD-3-Clause
import std/os
import nimbs/packagemetadata
const packageDir = "tests" / "nimble" / "packagemetadata" / "packageA-0.1.0"
assert getUrl(packageDir) == "https://example.com"

Some files were not shown because too many files have changed in this diff Show More