├── .gitignore ├── LICENSE ├── META6.json ├── README.md ├── bin └── z ├── config.json.template └── lib └── RDev.pm6 /.gitignore: -------------------------------------------------------------------------------- 1 | /lib/.precomp 2 | /config.json 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The Artistic License 2.0 2 | 3 | Copyright (c) 2000-2006, The Perl Foundation. 4 | 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | This license establishes the terms under which a given free software 11 | Package may be copied, modified, distributed, and/or redistributed. 12 | The intent is that the Copyright Holder maintains some artistic 13 | control over the development of that Package while still keeping the 14 | Package available as open source and free software. 15 | 16 | You are always permitted to make arrangements wholly outside of this 17 | license directly with the Copyright Holder of a given Package. If the 18 | terms of this license do not permit the full use that you propose to 19 | make of the Package, you should contact the Copyright Holder and seek 20 | a different licensing arrangement. 21 | 22 | Definitions 23 | 24 | "Copyright Holder" means the individual(s) or organization(s) 25 | named in the copyright notice for the entire Package. 26 | 27 | "Contributor" means any party that has contributed code or other 28 | material to the Package, in accordance with the Copyright Holder's 29 | procedures. 30 | 31 | "You" and "your" means any person who would like to copy, 32 | distribute, or modify the Package. 33 | 34 | "Package" means the collection of files distributed by the 35 | Copyright Holder, and derivatives of that collection and/or of 36 | those files. A given Package may consist of either the Standard 37 | Version, or a Modified Version. 38 | 39 | "Distribute" means providing a copy of the Package or making it 40 | accessible to anyone else, or in the case of a company or 41 | organization, to others outside of your company or organization. 42 | 43 | "Distributor Fee" means any fee that you charge for Distributing 44 | this Package or providing support for this Package to another 45 | party. It does not mean licensing fees. 46 | 47 | "Standard Version" refers to the Package if it has not been 48 | modified, or has been modified only in ways explicitly requested 49 | by the Copyright Holder. 50 | 51 | "Modified Version" means the Package, if it has been changed, and 52 | such changes were not explicitly requested by the Copyright 53 | Holder. 54 | 55 | "Original License" means this Artistic License as Distributed with 56 | the Standard Version of the Package, in its current version or as 57 | it may be modified by The Perl Foundation in the future. 58 | 59 | "Source" form means the source code, documentation source, and 60 | configuration files for the Package. 61 | 62 | "Compiled" form means the compiled bytecode, object code, binary, 63 | or any other form resulting from mechanical transformation or 64 | translation of the Source form. 65 | 66 | 67 | Permission for Use and Modification Without Distribution 68 | 69 | (1) You are permitted to use the Standard Version and create and use 70 | Modified Versions for any purpose without restriction, provided that 71 | you do not Distribute the Modified Version. 72 | 73 | 74 | Permissions for Redistribution of the Standard Version 75 | 76 | (2) You may Distribute verbatim copies of the Source form of the 77 | Standard Version of this Package in any medium without restriction, 78 | either gratis or for a Distributor Fee, provided that you duplicate 79 | all of the original copyright notices and associated disclaimers. At 80 | your discretion, such verbatim copies may or may not include a 81 | Compiled form of the Package. 82 | 83 | (3) You may apply any bug fixes, portability changes, and other 84 | modifications made available from the Copyright Holder. The resulting 85 | Package will still be considered the Standard Version, and as such 86 | will be subject to the Original License. 87 | 88 | 89 | Distribution of Modified Versions of the Package as Source 90 | 91 | (4) You may Distribute your Modified Version as Source (either gratis 92 | or for a Distributor Fee, and with or without a Compiled form of the 93 | Modified Version) provided that you clearly document how it differs 94 | from the Standard Version, including, but not limited to, documenting 95 | any non-standard features, executables, or modules, and provided that 96 | you do at least ONE of the following: 97 | 98 | (a) make the Modified Version available to the Copyright Holder 99 | of the Standard Version, under the Original License, so that the 100 | Copyright Holder may include your modifications in the Standard 101 | Version. 102 | 103 | (b) ensure that installation of your Modified Version does not 104 | prevent the user installing or running the Standard Version. In 105 | addition, the Modified Version must bear a name that is different 106 | from the name of the Standard Version. 107 | 108 | (c) allow anyone who receives a copy of the Modified Version to 109 | make the Source form of the Modified Version available to others 110 | under 111 | 112 | (i) the Original License or 113 | 114 | (ii) a license that permits the licensee to freely copy, 115 | modify and redistribute the Modified Version using the same 116 | licensing terms that apply to the copy that the licensee 117 | received, and requires that the Source form of the Modified 118 | Version, and of any works derived from it, be made freely 119 | available in that license fees are prohibited but Distributor 120 | Fees are allowed. 121 | 122 | 123 | Distribution of Compiled Forms of the Standard Version 124 | or Modified Versions without the Source 125 | 126 | (5) You may Distribute Compiled forms of the Standard Version without 127 | the Source, provided that you include complete instructions on how to 128 | get the Source of the Standard Version. Such instructions must be 129 | valid at the time of your distribution. If these instructions, at any 130 | time while you are carrying out such distribution, become invalid, you 131 | must provide new instructions on demand or cease further distribution. 132 | If you provide valid instructions or cease distribution within thirty 133 | days after you become aware that the instructions are invalid, then 134 | you do not forfeit any of your rights under this license. 135 | 136 | (6) You may Distribute a Modified Version in Compiled form without 137 | the Source, provided that you comply with Section 4 with respect to 138 | the Source of the Modified Version. 139 | 140 | 141 | Aggregating or Linking the Package 142 | 143 | (7) You may aggregate the Package (either the Standard Version or 144 | Modified Version) with other packages and Distribute the resulting 145 | aggregation provided that you do not charge a licensing fee for the 146 | Package. Distributor Fees are permitted, and licensing fees for other 147 | components in the aggregation are permitted. The terms of this license 148 | apply to the use and Distribution of the Standard or Modified Versions 149 | as included in the aggregation. 150 | 151 | (8) You are permitted to link Modified and Standard Versions with 152 | other works, to embed the Package in a larger work of your own, or to 153 | build stand-alone binary or bytecode versions of applications that 154 | include the Package, and Distribute the result without restriction, 155 | provided the result does not expose a direct interface to the Package. 156 | 157 | 158 | Items That are Not Considered Part of a Modified Version 159 | 160 | (9) Works (including, but not limited to, modules and scripts) that 161 | merely extend or make use of the Package, do not, by themselves, cause 162 | the Package to be a Modified Version. In addition, such works are not 163 | considered parts of the Package itself, and are not subject to the 164 | terms of this license. 165 | 166 | 167 | General Provisions 168 | 169 | (10) Any use, modification, and distribution of the Standard or 170 | Modified Versions is governed by this Artistic License. By using, 171 | modifying or distributing the Package, you accept this license. Do not 172 | use, modify, or distribute the Package, if you do not accept this 173 | license. 174 | 175 | (11) If your Modified Version has been derived from a Modified 176 | Version made by someone other than you, you are nevertheless required 177 | to ensure that your Modified Version complies with the requirements of 178 | this license. 179 | 180 | (12) This license does not grant you the right to use any trademark, 181 | service mark, tradename, or logo of the Copyright Holder. 182 | 183 | (13) This license includes the non-exclusive, worldwide, 184 | free-of-charge patent license to make, have made, use, offer to sell, 185 | sell, import and otherwise transfer the Package with respect to any 186 | patent claims licensable by the Copyright Holder that are necessarily 187 | infringed by the Package. If you institute patent litigation 188 | (including a cross-claim or counterclaim) against any party alleging 189 | that the Package constitutes direct or contributory patent 190 | infringement, then this Artistic License to you shall terminate on the 191 | date that such litigation is filed. 192 | 193 | (14) Disclaimer of Warranty: 194 | THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS 195 | IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED 196 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 197 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL 198 | LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL 199 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 200 | DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF 201 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 202 | 203 | -------------------------------------------------------------------------------- /META6.json: -------------------------------------------------------------------------------- 1 | { 2 | "perl" : "6.c", 3 | "name" : "Z-Script", 4 | "license" : "Artistic-2.0", 5 | "version" : "1.001003", 6 | "description" : "Helper script for Rakudo Perl 6 core development", 7 | "tags" : [ "core dev" ], 8 | "depends" : [ 9 | "Config::JSON", 10 | "Temp::Path" 11 | ], 12 | "test-depends" : [ 13 | ], 14 | "provides" : { 15 | "RDev" : "lib/RDev.pm6" 16 | }, 17 | "authors" : ["Zoffix Znet"], 18 | "support" : {"source" : "https://github.com/zoffixznet/z.git"} 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Z-Script 2 | 3 | Helper script for Rakudo core development 4 | 5 | # INSTALLATION 6 | 7 | ```bash 8 | git clone https://github.com/zoffixznet/z ~/zscript && 9 | cd ~/zscript && 10 | zef --depsonly install . 11 | 12 | echo 'export PATH="$HOME/zscript/bin:$PATH"' >> ~/.bashrc 13 | . ~/.bashrc 14 | 15 | z init ~/R # or some other dir you wanna use for all the repos 16 | ``` 17 | 18 | **This installs command `z` into your PATH.** 19 | 20 | If you want to call `z` by a different name (for instance, if you use the popular [`z` script](https://github.com/rupa/z) included in several Linux distributions), you should be aware that (this) `z` uses libraries relative to its own directory. So some typical workarounds for this, like creating a _~/bin/p6z_ → _~/zscript/bin/z_ symbolic link, will make `z` run incorrectly. 21 | 22 | The easiest way to deal with this is by using a shell alias (_instead_ of the above): 23 | 24 | ```bash 25 | echo 'alias p6z="$HOME/zscript/bin/z"' >> ~/.bashrc 26 | . ~/.bashrc 27 | 28 | p6z init ~/R 29 | ``` 30 | 31 | 32 | # ENV VARS 33 | 34 | You can set `ZSCRIPT_DIR` env var to change which build dir Z-Script uses. 35 | Otherwise, `dir` config value is used (this is the dir you provided to 36 | `z init`). This var allows you to have multiple build dirs. 37 | 38 | # COMMAND REFERENCE 39 | 40 | **BELOW LIST IS NO LONGER KEPT UP-TO-DATE. RUN `z --help` TO SEE ALL THE 41 | OPTIONS* 42 | 43 | ``` 44 | z init Some-Dir # clone all repos and build everything inside Some-Dir 45 | # Some-Dir defaults to `.`; must be empty 46 | 47 | z z # pulls all repos and rebuilds MoarVM, nqp, and Rakudo from scratch 48 | z f # pulls updates into all repos 49 | z # re-make rakudo 50 | z --test # re-make rakudo + run make test 51 | z n # re-make nqp and rakudo 52 | z n --test # re-make nqp and rakudo + run make test for both 53 | z m # re-make MoarVM 54 | z md # re-make MoarVM after reconf with DEBUG (with --no-optimize) 55 | z mnd # re-make MoarVM after reconf with no DEBUG 56 | 57 | z s # run rakudo's make test + spectest 58 | z ss # run rakudo's make test + stresstest 59 | z bs # run "best test" (have > 10 cores ?? stresstest !! spectest) 60 | z t some files # run t/fudgeandrun some files 61 | 62 | z bump # bump MoarVM and nqp + best test + bump push on success 63 | z bump --no-push # bump MoarVM and nqp + best test, but don't push 64 | z bump m # bump MoarVM version 65 | z bump n # bump nqp version 66 | z bump push # push already-done version bumps for MoarVM and nqp 67 | z bump push m # push already-done version bump for MoarVM 68 | z bump push n # push already-done version bump for nqp 69 | 70 | z mod Some Module # install modules 'Some' and 'Module', without tests 71 | z mod Some Module --tests # install modules 'Some' and 'Module', with tests 72 | z umod Some Module # uninstall modules 'Some' and 'Module' 73 | z modi5 # install Inline::Perl5 module 74 | 75 | z conf # print all configuration 76 | z conf dir # print value for configuration key "dir" 77 | z conf dir /home/zoffix/R # set config key "dir" to value "/home/zoffix/R" 78 | 79 | vm 111.222.333.444 # set VM IP to given IP (trims surrounding whitespace) 80 | vm # rsyncs all local changes to VM 81 | vm s # sync spec changes 82 | vm d # sync doc changes 83 | vm m # sync moar changes 84 | vm n # sync nqp changes 85 | vm r # sync rakudo changes 86 | vm SCRUB # run `git reset --hard` in all local repos and pull 87 | # new commits. This *** DELETES ALL LOCAL YOUR CHANGES *** 88 | # Yup. LOCAL, not VM. It's under `vm` because you'd use 89 | # this command to sync local when editing locally and 90 | # committing remotely 91 | 92 | 93 | z q # opens Grammar/Actions/World/Optimizer in atom editor; assumes we're 94 | # in the root of a rakudo checkout 95 | 96 | z r Some Command # run Some Command in all the repos (may have issues with 97 | # named args) 98 | 99 | 100 | # full-cycle builds are only needed when you need to 101 | # re-run Configure.pl if, say, core files were added/deleted 102 | z build moar # full-cycle build moarvm 103 | z build nqp # full-cycle build nqp 104 | z build rakudo # full-cycle build rakduo 105 | ``` 106 | 107 | ---- 108 | 109 | #### REPOSITORY 110 | 111 | Fork this module on GitHub: 112 | https://github.com/zoffixznet/z 113 | 114 | #### BUGS 115 | 116 | To report bugs or request features, please use 117 | https://github.com/zoffixznet/z/issues 118 | 119 | #### AUTHOR 120 | 121 | Zoffix Znet (http://perl6.party/) 122 | 123 | #### LICENSE 124 | 125 | You can use and distribute this module under the terms of the 126 | The Artistic License 2.0. See the `LICENSE` file included in this 127 | distribution for complete details. 128 | 129 | The `META6.json` file of this distribution may be distributed and modified 130 | without restrictions or attribution. 131 | -------------------------------------------------------------------------------- /bin/z: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl6 2 | 3 | use lib $*PROGRAM.sibling: '../lib'; 4 | my $conf := $*PROGRAM.sibling: '../config.json'; 5 | $conf.e or $conf.spurt: '{}'; 6 | 7 | use RDev; 8 | 9 | my $rd := RDev.new: :$conf; 10 | my %*SUB-MAIN-OPTS = :named-anywhere; 11 | 12 | #|(remake rakudo, optionally running tests) 13 | multi MAIN(Bool :$test) { 14 | $rd.re-make-rakudo: :$test; 15 | } 16 | 17 | #|(pull all and rebuild all from scratch) 18 | multi MAIN('z', Bool :$test, Bool :$jvm, Bool :$moar = True) { 19 | $rd.pull-all; 20 | $rd.build-moar if $moar; 21 | $rd.build-nqp: :$test, :$jvm, :$moar; 22 | $rd.build-rakudo: :$test, :$jvm, :$moar; 23 | } 24 | #|(pull all) 25 | multi MAIN('f') { $rd.pull-all; } 26 | #|(remake nqp and rakudo) 27 | multi MAIN('n', Bool :$test) { 28 | $rd.re-make-nqp: :$test; 29 | $rd.re-make-rakudo: :$test, :clean; 30 | } 31 | #|(remake moar) 32 | multi MAIN('m') { $rd.re-make-moar; } 33 | #|(remake moar, with debug mode enabled) 34 | multi MAIN('md') { $rd.re-make-moar-debug; } 35 | #|(build moar from scratch (useful to disable debug mode)) 36 | multi MAIN('mnd') { $rd.build-moar; } 37 | 38 | #|(run "best" test) 39 | multi MAIN('bs') { $rd.best-test; } 40 | #|(run spectest) 41 | multi MAIN('s') { $rd.spectest; } 42 | #|(run stresstest) 43 | multi MAIN('ss') { $rd.stresstest; } 44 | #|(fudgeandrun tests) 45 | multi MAIN('t', *@tests) { $rd.fudge-test: @tests; } 46 | 47 | #|(bump moar and rakudo, run "best", test and push) 48 | multi MAIN('bump', Bool :$no-push) { 49 | $rd.bump-nqp: $rd.bump-moar; 50 | $rd.build-moar; 51 | $rd.build-nqp: :test; 52 | $rd.build-rakudo: :test; 53 | unless $rd.best-test { 54 | exit if $no-push 55 | or 'y' ne lc prompt 'Had some test failures. Push anyway? [N/y]: ' 56 | } 57 | $no-push or $rd.bump-push; 58 | } 59 | #|(bump moar) 60 | multi MAIN('bump', 'm') { $rd.bump-moar; } 61 | #|(bump nqp) 62 | multi MAIN('bump', 'n') { $rd.bump-nqp; } 63 | #|(push prepared bumps) 64 | multi MAIN('bump', 'push') { $rd.bump-push; } 65 | #|(push prepared moar bump) 66 | multi MAIN('bump', 'push', 'm') { $rd.bump-push-moar; } 67 | #|(push prepared nqp bump) 68 | multi MAIN('bump', 'push', 'n') { $rd.bump-push-nqp; } 69 | 70 | #|(initialize new install, cloning all repos into dir) 71 | multi MAIN('init', $dir = '.'.IO, 72 | Bool :$jvm, Bool :$moar = True, Bool :$test = True, 73 | Bool :$clone-only, 74 | ) { 75 | $rd.init: $dir; 76 | if $clone-only { 77 | say "--clone-only set; exiting without building"; 78 | $rd.make-links; 79 | exit; 80 | } 81 | $rd.build-moar if $moar; 82 | $rd.build-nqp: :$test, :$jvm, :$moar; 83 | $rd.build-rakudo: :$test, :$jvm, :$moar; 84 | $rd.make-links; 85 | MAIN 'modi5'; 86 | } 87 | #|(use full cycle to build moar) 88 | multi MAIN('build', 'moar') { $rd.build-moar; } 89 | #|(use full cycle to build nqp) 90 | multi MAIN('build', 'nqp', Bool :$jvm, Bool :$moar = True, Bool :$test) { 91 | $rd.build-nqp: :$test, :$jvm, :$moar; 92 | } 93 | #|(use full cycle to build rakudo) 94 | multi MAIN('build', 'rakudo', Bool :$jvm, Bool :$moar = True, Bool :$test) { 95 | $rd.build-rakudo: :$test, :$jvm, :$moar; 96 | } 97 | 98 | #|(install Inline::Perl5) 99 | multi MAIN('modi5') { 100 | $rd.install-modules: ['Inline::Perl5'], :!tests; 101 | } 102 | 103 | #|(install modules, optionally running their tests) 104 | multi MAIN('mod', *@modules-to-install where +*, Bool :$tests) { 105 | $rd.install-modules: @modules-to-install, :$tests; 106 | } 107 | #|(uninstall modules) 108 | multi MAIN('umod', *@modules-to-uninstall where +*) { 109 | $rd.uninstall-modules: @modules-to-uninstall; 110 | } 111 | #|(make symlinks to perl6 binary) 112 | multi MAIN(:$links!) { $rd.make-links; } 113 | 114 | 115 | ### Config options 116 | #|(display config property (or all if no name is specified)) 117 | multi MAIN('conf', $conf-prop-name = *) { $rd.print-conf: $conf-prop-name } 118 | #|(set config property to given value) 119 | multi MAIN('conf', Str:D $conf-prop-name, Str:D $value) { 120 | $rd.set-conf: $conf-prop-name, $value; 121 | } 122 | 123 | ### VM options 124 | #|(set IP of remote VM (also can be set via `conf`)) 125 | multi MAIN('vm', Str:D $ip where /^\s*[\d**1..3\.]**3\d**1..3\s*$/) { 126 | say "Saved VM IP as " ~ $rd.set-conf: 'vm-ip', $ip.trim; 127 | } 128 | #|(sync all repos with remote VM) 129 | multi MAIN('vm') { $rd.sync-vm } 130 | #|(sync spec repo with remote VM) 131 | multi MAIN('vm', 's') { $rd.sync-vm-spec } 132 | #|(sync doc repo with remote VM) 133 | multi MAIN('vm', 'd') { $rd.sync-vm-doc } 134 | #|(sync moar repo with remote VM) 135 | multi MAIN('vm', 'm') { $rd.sync-vm-moar } 136 | #|(sync nqp repo with remote VM) 137 | multi MAIN('vm', 'n') { $rd.sync-vm-nqp } 138 | #|(sync rakudo repo with remote VM) 139 | multi MAIN('vm', 'r') { $rd.sync-vm-rak } 140 | #|(git reset --hard and pull all LOCAL repos) 141 | multi MAIN('vm', 'SCRUB') { $rd.vm-SCRUB } 142 | 143 | 144 | ### Editor options 145 | #|(open atom to Grammar/Actions/World/Optimizer) 146 | multi MAIN('q') { 147 | $rd.run-rak: %*ENV || 'atom', «src/Perl6/Grammar.nqp src/Perl6/Actions.nqp 148 | src/Perl6/World.nqp src/Perl6/Optimizer.nqp»; 149 | } 150 | 151 | 152 | ### Exec options 153 | #|(run a command in all repos) 154 | multi MAIN('r', *@args) { 155 | $rd.run-in-all: @args 156 | } 157 | -------------------------------------------------------------------------------- /config.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "dir": "/home/zoffix/R" 3 | } 4 | -------------------------------------------------------------------------------- /lib/RDev.pm6: -------------------------------------------------------------------------------- 1 | unit class RDev; 2 | use Temp::Path; 3 | use Config::JSON ''; 4 | 5 | has IO::Path:D $.conf is required; 6 | has &!c = &jconf .assuming: $!conf; 7 | has &!cw = &jconf-write.assuming: $!conf; 8 | has IO::Path $!dir; 9 | has Str $!rak; 10 | has Str $!nqp; 11 | has Str $!doc; 12 | has Str $!moar; 13 | has Str $!spec; 14 | has Str $!inst; 15 | has Int $!cores = Kernel.cpu-cores * 2; 16 | 17 | submethod TWEAK { self!init-dirs } 18 | method !init-dirs { 19 | with (%*ENV || &!c('dir')) -> IO() $_ { 20 | $!dir = $_; 21 | $!rak = .add('rakudo' ).absolute; 22 | $!nqp = .add('nqp' ).absolute; 23 | $!doc = .add('doc' ).absolute; 24 | $!moar = .add('MoarVM' ).absolute; 25 | $!inst = .add('install').absolute; 26 | $!spec = .add('rakudo/t/spec/').absolute; 27 | } 28 | else { 29 | warn '"dir" key not found in config. Please run `init` command.' 30 | ~ ' If you are running it right now, then ignore this warning.' 31 | } 32 | } 33 | 34 | method init (IO() $!dir = '.'.IO) { 35 | $!dir.dir.so and die "Init dir `$!dir.absolute()` must be empty."; 36 | &!cw('dir', $!dir.absolute); 37 | self!init-dirs; 38 | .mkdir for $!dir, $!rak.IO, $!nqp.IO, $!moar.IO, $!inst.IO; 39 | run «git clone https://github.com/rakudo/rakudo "$!rak"»; 40 | run «git clone https://github.com/Raku/roast "$!spec"»; 41 | run «git clone https://github.com/Raku/nqp "$!nqp"»; 42 | run «git clone https://github.com/Raku/doc "$!doc"»; 43 | run «git clone https://github.com/MoarVM/MoarVM "$!moar"»; 44 | } 45 | 46 | method make-links { 47 | $!inst.IO.add('bin/perl6-m').symlink: $!dir.add: 'perl6'; 48 | } 49 | 50 | method best-test { 51 | $!cores > 10 ?? self.stresstest !! self.spectest; 52 | } 53 | 54 | method bump-moar { 55 | self!pull-moar; 56 | self!pull-nqp; 57 | 58 | my $ver-file = $!nqp.IO.add: 'tools/templates/MOAR_REVISION'; 59 | 60 | my $before = $ver-file.slurp.trim; 61 | my $after = self!run-moar-out: «git describe»; 62 | if $before eq $after { 63 | note "\n\n### No fresh commits in MoarVM; no bumping is needed\n\n"; 64 | exit; 65 | } 66 | $ver-file.spurt: "$after\n"; 67 | 68 | my $log = self!run-moar-out: «git log --oneline "$before...$after"»; 69 | unless my $n-commits := +$log.lines { 70 | note "\n\n### No fresh commits in MoarVM; no bumping is needed\n\n"; 71 | exit; 72 | } 73 | my $title = "[MoarVM Bump] Brings $n-commits commit" 74 | ~ ("s" if $n-commits > 1); 75 | 76 | if $log.lines == 1 { 77 | $title = "[MoarVM Bump] " ~ self!trim: $log, 36; 78 | $log = ''; 79 | } 80 | $log = "MoarVM bump brought: " 81 | ~ "https://github.com/MoarVM/MoarVM/compare/$before...$after" 82 | ~ ("\n$log\n" if $log); 83 | say "$title\n\n$log".indent: 8; 84 | self!run-nqp: «git commit "$ver-file.absolute()" -m "$title" -m "$log"»; 85 | $log 86 | } 87 | 88 | method bump-nqp (Str:D $moar-log = '') { 89 | self!pull-nqp; 90 | self!pull-rak; 91 | 92 | my $ver-file = $!rak.IO.add: 'tools/templates/NQP_REVISION'; 93 | 94 | my $before = $ver-file.slurp.trim; 95 | my $after = self!run-nqp-out: «git describe»; 96 | if $before eq $after { 97 | note "\n\n### No fresh commits in NQP; no bumping is needed\n\n"; 98 | exit; 99 | } 100 | $ver-file.spurt: "$after\n"; 101 | 102 | my $log = self!run-nqp-out: «git log --oneline "$before...$after"»; 103 | unless my $n-commits := +$log.lines { 104 | note "\n\n### No fresh commits in NQP; no bumping is needed\n\n"; 105 | exit; 106 | } 107 | my $title = "[NQP Bump] Brings $n-commits commit" 108 | ~ ("s" if $n-commits > 1); 109 | if $log.lines == 1 { 110 | $title = "[NQP Bump] " ~ self!trim: $log, 39; 111 | $log = ''; 112 | } 113 | $log = "NQP bump brought: " 114 | ~ "https://github.com/perl6/nqp/compare/$before...$after" 115 | ~ ("\n$log\n" if $log) 116 | ~ ("\n\n$moar-log\n" if $moar-log); 117 | 118 | say "$title\n\n$log".indent: 8; 119 | self!run-rak: «git commit "$ver-file.absolute()" -m "$title" -m "$log"»; 120 | $log 121 | } 122 | 123 | method bump-push { 124 | self.bump-push-moar; 125 | self.bump-push-nqp; 126 | } 127 | method bump-push-moar { 128 | self!run-nqp: «git pull --rebase»; 129 | self!run-nqp: «git push»; 130 | } 131 | method bump-push-nqp { 132 | self!run-rak: «git pull --rebase»; 133 | self!run-rak: «git push»; 134 | } 135 | 136 | method pull-all { 137 | say "Pulling MoarVM"; 138 | self!pull-moar; 139 | say "Pulling NQP"; 140 | self!pull-nqp; 141 | say "Pulling Rakudo"; 142 | self!pull-rak; 143 | say "Pulling Roast"; 144 | self!pull-spec; 145 | say "Pulling Docs"; 146 | self!pull-doc; 147 | } 148 | method !pull-moar { self!run-moar: «git pull --rebase» } 149 | method !pull-nqp { self!run-nqp: «git pull --rebase» } 150 | method !pull-rak { self!run-rak: «git pull --rebase» } 151 | method !pull-spec { self!run-spec: «git pull --rebase» } 152 | method !pull-doc { self!run-doc: «git pull --rebase» } 153 | 154 | method run-in-all (@args --> Nil) { 155 | say "Running in MoarVM"; 156 | my $ = self!run-moar: @args; 157 | say "Running in NQP"; 158 | my $ = self!run-nqp: @args; 159 | say "Running in Rakudo"; 160 | my $ = self!run-rak: @args; 161 | say "Running in Roast"; 162 | my $ = self!run-spec: @args; 163 | say "Running in Docs"; 164 | my $ = self!run-doc: @args; 165 | } 166 | 167 | method !init-zef { 168 | temp %*ENV = my $path = join ($*DISTRO.is-win ?? ";" !! ":"), 169 | $!inst.IO.add('bin').absolute, 170 | $!inst.IO.add('share/perl6/site/bin').absolute, 171 | $*SPEC.path; 172 | 173 | unless run :!out, :!err, «zef --help» { 174 | indir make-temp-dir, { 175 | run «git clone https://github.com/ugexe/zef .»; 176 | run «perl6 -Ilib bin/zef install .»; 177 | } 178 | } 179 | 180 | $path; 181 | } 182 | method install-modules(@mods, Bool :$tests) { 183 | temp %*ENV = self!init-zef; 184 | run «zef --debug --/serial», |('--/test' unless $tests), 'install', |@mods; 185 | } 186 | method uninstall-modules(@mods) { 187 | temp %*ENV = self!init-zef; 188 | run «zef --debug uninstall», |@mods; 189 | } 190 | 191 | method spectest { 192 | self!run-rak: «make install»; 193 | self!run-rak: «make test»; 194 | self!run-rak: «make spectest»; 195 | } 196 | method stresstest { 197 | self!run-rak: «make install»; 198 | self!run-rak: «make test»; 199 | self!run-rak: «make stresstest»; 200 | } 201 | method fudge-test (*@tests) { 202 | self!run-rak: 't/fudgeandrun', @tests; 203 | } 204 | 205 | method re-make-moar-debug { 206 | self!run-moar: «perl Configure.pl "--prefix=$!inst" --no-optimize --debug=3»; 207 | self.re-make-moar 208 | } 209 | method re-make-moar { 210 | self!run-moar: «make "-j$!cores"»; 211 | self!run-moar: «make install»; 212 | } 213 | method re-make-nqp(Bool :$test) { 214 | self!run-nqp: «make clean»; 215 | self!run-nqp: «make "-j$!cores"»; 216 | self!run-nqp: «make test» if $test; 217 | self!run-nqp: «make install»; 218 | } 219 | method re-make-rakudo(Bool :$test, Bool :$clean) { 220 | self!run-rak: «make clean» if $clean; 221 | self!run-rak: «make "-j$!cores"»; 222 | self!run-rak: «make test» if $test; 223 | self!run-rak: «make install»; 224 | } 225 | 226 | method build-moar { 227 | (self!run-rak: «make realclean»).so; 228 | self!run-moar: «perl Configure.pl "--prefix=$!inst"»; 229 | self!run-moar: «make "-j$!cores"»; 230 | self!run-moar: «make install»; 231 | } 232 | 233 | method build-nqp(Bool :$test, Bool :$jvm, Bool :$moar = True) { 234 | my $b = join ',', ('moar' if $moar), ('jvm' if $jvm); 235 | (self!run-rak: «make realclean»).so; 236 | self!run-nqp: «perl Configure.pl "--prefix=$!inst" "--backends=$b"»; 237 | self!run-nqp: «make "-j$!cores"»; 238 | self!run-nqp: «make test» if $test; 239 | self!run-nqp: «make install»; 240 | } 241 | 242 | method build-rakudo (Bool :$test, Bool :$jvm, Bool :$moar = True) { 243 | my $b = join ',', ('moar' if $moar), ('jvm' if $jvm); 244 | (self!run-rak: «make realclean»).so; 245 | self!run-rak: «perl Configure.pl "--prefix=$!inst" "--backends=$b"»; 246 | self!run-rak: «make "-j$!cores"»; 247 | self!run-rak: «make test» if $test; 248 | self!run-rak: «make install»; 249 | } 250 | 251 | method !run-inst (|c) { run :cwd($!inst), |c } 252 | method !run-moar (|c) { run :cwd($!moar), |c } 253 | method !run-nqp (|c) { run :cwd($!nqp), |c } 254 | method !run-rak (|c) { run :cwd($!rak), |c } 255 | method run-rak (|c) { self!run-rak: |c } 256 | method !run-spec (|c) { run :cwd($!spec), |c } 257 | method !run-doc (|c) { run :cwd($!doc), |c } 258 | 259 | method !run-inst-out (|c) { self!run-inst(|c, :out).out.slurp(:close).trim } 260 | method !run-moar-out (|c) { self!run-moar(|c, :out).out.slurp(:close).trim } 261 | method !run-nqp-out (|c) { self!run-nqp( |c, :out).out.slurp(:close).trim } 262 | method !run-rak-out (|c) { self!run-rak( |c, :out).out.slurp(:close).trim } 263 | method !run-spec-out (|c) { self!run-spec(|c, :out).out.slurp(:close).trim } 264 | method !run-doc-out (|c) { self!run-doc( |c, :out).out.slurp(:close).trim } 265 | 266 | method !trim (Str:D $str, UInt:D $max) { 267 | $str.chars > $max 268 | ?? $str.substr(0, $max-4) ~ ' […]' 269 | !! $str 270 | } 271 | 272 | 273 | multi method print-conf (Str:D $prop) { say &!c($prop) // 'no such property' } 274 | multi method print-conf (Whatever) { 275 | say .fmt: '%-20s => %-20s' for &!c(*) 276 | } 277 | method set-conf (Str:D $prop, Str:D $value) { 278 | &!cw($prop, $value); 279 | $value 280 | } 281 | 282 | method !sync-vm-creds { 283 | my ($ip, $user, $dir-to, $dir-from) 284 | = &!c('vm-ip'), &!c('vm-user'), &!c('vm-dir'), &!c('dir'); 285 | if $ip ~~ Failure { 286 | $ip = trim prompt 'No VM IP. Gimme: '; 287 | &!cw('vm-ip', $ip) 288 | } 289 | if $user ~~ Failure { 290 | $user = trim prompt 'No VM user. Gimme: '; 291 | &!cw('vm-user', $user) 292 | } 293 | if $dir-to ~~ Failure { 294 | my $dir = prompt "No VM dir specified. What to use? [$dir-from]: "; 295 | $dir-to = $dir || $dir-from; 296 | $dir-to.IO.is-absolute or die "Must be absolute path"; 297 | &!cw('vm-dir', $dir-to); 298 | } 299 | .subst: / '/'+ $ /, '' for $dir-to, $dir-from; 300 | ($ip, $user, $dir-to, $dir-from) 301 | } 302 | method sync-vm { 303 | self.sync-vm-spec; 304 | self.sync-vm-doc; 305 | self.sync-vm-moar; 306 | self.sync-vm-nqp; 307 | self.sync-vm-rak; 308 | } 309 | method sync-vm-spec { 310 | my ($ip, $user, $dir-to, $dir-from) = self!sync-vm-creds; 311 | self!run-spec-out(«git status --porcelain»).lines.map: { 312 | my $file := .trim.split(/\s+/, 2).tail; 313 | my $from := "$dir-from/rakudo/t/spec/$file"; 314 | my $to := "$dir-to/rakudo/t/spec/$file"; 315 | self!run-inst: 316 | «rsync -avz --del -h --exclude .precomp --delete-missing-args», 317 | $from, "$user\@$ip:$to"; 318 | } 319 | } 320 | 321 | method sync-vm-doc { 322 | my ($ip, $user, $dir-to, $dir-from) = self!sync-vm-creds; 323 | self!run-doc-out(«git status --porcelain»).lines.map: { 324 | my $file := .trim.split(/\s+/, 2).tail; 325 | my $from := "$dir-from/doc/$file"; 326 | my $to := "$dir-to/doc/$file"; 327 | self!run-inst: 328 | «rsync -avz --del -h --exclude .precomp --delete-missing-args», 329 | $from, "$user\@$ip:$to"; 330 | } 331 | } 332 | 333 | method sync-vm-moar { 334 | my ($ip, $user, $dir-to, $dir-from) = self!sync-vm-creds; 335 | self!run-moar-out(«git status --porcelain»).lines.map: { 336 | my $file := .trim.split(/\s+/, 2).tail; 337 | my $from := "$dir-from/MoarVM/$file"; 338 | my $to := "$dir-to/MoarVM/$file"; 339 | self!run-inst: 340 | «rsync -avz --del -h --exclude .precomp --delete-missing-args», 341 | $from, "$user\@$ip:$to"; 342 | } 343 | } 344 | 345 | method sync-vm-nqp { 346 | my ($ip, $user, $dir-to, $dir-from) = self!sync-vm-creds; 347 | self!run-nqp-out(«git status --porcelain»).lines.map: { 348 | my $file := .trim.split(/\s+/, 2).tail; 349 | my $from := "$dir-from/nqp/$file"; 350 | my $to := "$dir-to/nqp/$file"; 351 | self!run-inst: 352 | «rsync -avz --del -h --exclude .precomp --delete-missing-args», 353 | $from, "$user\@$ip:$to"; 354 | } 355 | } 356 | 357 | method sync-vm-rak { 358 | my ($ip, $user, $dir-to, $dir-from) = self!sync-vm-creds; 359 | self!run-rak-out(«git status --porcelain»).lines.map: { 360 | my $file := .trim.split(/\s+/, 2).tail; 361 | my $from := "$dir-from/rakudo/$file"; 362 | my $to := "$dir-to/rakudo/$file"; 363 | self!run-inst: 364 | «rsync -rlpgoD -vz --del -h --delete-missing-args», 365 | $from, "$user\@$ip:$to"; 366 | } 367 | } 368 | 369 | method vm-SCRUB { 370 | if prompt('SCRUB stuff? Are you sure? [y/N]: ').lc eq 'y' { 371 | self!run-moar: «git reset --hard»; 372 | self!run-nqp: «git reset --hard»; 373 | self!run-rak: «git reset --hard»; 374 | self!run-spec: «git reset --hard»; 375 | self!run-doc: «git reset --hard»; 376 | self.pull-all; 377 | } 378 | else { 379 | say "OK. Aborting"; 380 | } 381 | } 382 | --------------------------------------------------------------------------------