@@ -147,7 +147,7 @@ my $mem_per_core_vircadia = 1 * 1024 * 1024;
147147# Qt has a build stage that consumes a huge amount of RAM. Be a bit conservative here.
148148my $mem_per_core_qt = 1.2 * 1024 * 1024;
149149
150- my $repo = " https://github.com/vircadia/vircadia " ;
150+ my $repo ;
151151my $qt_repo = " git://code.qt.io/qt/qt5.git" ;
152152my $repo_tag ;
153153
@@ -171,7 +171,7 @@ my $using_system_qt;
171171my ($opt_keep_source , $opt_auto , $opt_build_qt , $opt_build , $opt_skip_build , $opt_skip_systemd_restart , $opt_no_modify_rpath , $opt_skip_install , $opt_make_appimage , $opt_install_deps_only , $opt_verbose );
172172my ($opt_qt_debug , $opt_qt_debug_info , $cmd_get_install_dir , $cmd_get_archive_name , $cmd_make_archive , $opt_debug );
173173my ($cmd_help , $cmd_get_supported , $cmd_get_source_deps , $cmd_get_qt_deps , $cmd_get_system_qt_deps , $cmd_get_qt_version , $cmd_get_qt_patches , $cmd_make_pkglist );
174- my $opt_fork ;
174+ my ( $opt_fork , $opt_pr ) ;
175175
176176$opt_build = " client" ;
177177
@@ -217,6 +217,7 @@ GetOptions(
217217 " debug" => \$opt_debug ,
218218 " optimization-level=s" => \$optimization_level ,
219219 " fork|F=s" => \$opt_fork ,
220+ " pr|P=s" => \$opt_pr ,
220221) or help(1);
221222
222223
@@ -238,8 +239,33 @@ load_data();
238239
239240
240241
242+ my $custom_fork ;
241243my $fork_name ;
242244
245+ if ( $opt_pr ) {
246+ if ( $opt_pr =~ m # https://github.com/vircadia/vircadia/pulls/(\d +)# ) {
247+ $opt_pr = $1 ;
248+ $opt_fork = " vircadia" ;
249+ } elsif ( $opt_pr =~ m # https://github.com/overte-org/overte/pull/(\d +)# ) {
250+ $opt_pr = $1 ;
251+ $opt_fork = " overte" ;
252+ } elsif ( $opt_pr =~ m # https://github.com/tivolicloud/interface/pull/(\d +)# ) {
253+ $opt_pr = $1 ;
254+ $opt_fork = " tivoli" ;
255+ } elsif ( $opt_pr =~ m # https://github.com/(\w +)/(\w +)/pull/(\d +)# ) {
256+ $opt_fork = $1 ;
257+ $repo = " https://github.com/$1 /$2 " ;
258+ $opt_pr = $3 ;
259+
260+ # This ensures we don't fail due to an unrecognized fork name later.
261+ $custom_fork = 1;
262+ } elsif ( $opt_pr =~ / ^(\d +)/ ) {
263+ # Nothing, PR number specified as-is
264+ } else {
265+ die " Invalid argument to --pr. Either pass a PR number, or a full URL to the PR on github" ;
266+ }
267+ }
268+
243269if ( !$opt_fork ) {
244270 my $exe = basename($0 );
245271 if ( $exe =~ / vircadia/i ) {
@@ -260,18 +286,18 @@ $opt_fork = lc($opt_fork);
260286
261287if ( $opt_fork eq " vircadia" ) {
262288 $fork_name = " Vircadia" ;
263- $repo = " https://github.com/vircadia/vircadia" ;
289+ $repo // = " https://github.com/vircadia/vircadia" ;
264290 $repo_tag //= " master" ;
265291} elsif ( $opt_fork eq " overte" ) {
266292 $fork_name = " Overte" ;
267- $repo = " https://github.com/overte-org/overte" ;
293+ $repo // = " https://github.com/overte-org/overte" ;
268294 $repo_tag //= " master" ;
269295} elsif ( $opt_fork eq " tivoli" ) {
270296 $fork_name = " Tivoli" ;
271- $repo = " https://github.com/tivolicloud/interface" ;
297+ $repo // = " https://github.com/tivolicloud/interface" ;
272298 $repo_tag //= " main" ;
273299} else {
274- die " Unrecognized fork: $opt_fork " ;
300+ die " Unrecognized fork: $opt_fork " unless ( $custom_fork ) ;
275301}
276302
277303debug(" Fork is $fork_name , repo $repo \n " );
@@ -657,7 +683,7 @@ sub get_source {
657683
658684 mkdir ($root_dir );
659685
660- get_source_from_git($repo , " source" , $repo_tag , no_submodules => 1);
686+ get_source_from_git($repo , " source" , $repo_tag , no_submodules => 1, pr => $opt_pr );
661687}
662688
663689sub build {
@@ -1417,7 +1443,16 @@ sub clone_repo {
14171443 @git_extra_args = @{$opts {git_args }};
14181444 }
14191445
1420- run(" git" , " clone" , " --progress" , $url , " $root_dir /$destdir " , " -b" , $tag );
1446+ if ( $opts {pr } ) {
1447+ my $pr = $opts {pr };
1448+ info(" Checking out PR $pr \n " );
1449+ run(" git" , " clone" , " --progress" , $url , " $root_dir /$destdir " );
1450+ run(" git" , " fetch" , " origin" , " pull/$pr /head:PR-$pr " );
1451+ run(" git" , " checkout" , " PR-$pr " );
1452+ } else {
1453+ run(" git" , " clone" , " --progress" , $url , " $root_dir /$destdir " , " -b" , $tag );
1454+ }
1455+
14211456 if (!$opts {' no_submodules' }) {
14221457 run(" git" , " -C" , " $root_dir /$destdir " , " submodule" , " update" , " -f" , " --init" , " --recursive" );
14231458 }
@@ -1437,7 +1472,15 @@ sub update_repo {
14371472 run(" git" , " fetch" , " origin" , " $tag :refs/remotes/origin/$tag " );
14381473 run(" git" , " submodule" , " update" , " -f" , " --init" , " --recursive" ) unless ($opts {' no_submodules' });
14391474 run(" git" , " clean" , " -f" );
1440- run(" git" , " checkout" , " origin/$tag " );
1475+
1476+ if ( $opts {pr } ) {
1477+ my $pr = $opts {pr };
1478+ info(" Checking out PR $pr \n " );
1479+ run(" git" , " fetch" , " origin" , " pull/$pr /head:PR-$pr " );
1480+ run(" git" , " checkout" , " PR-$pr " );
1481+ } else {
1482+ run(" git" , " checkout" , " origin/$tag " );
1483+ }
14411484 }
14421485
14431486}
@@ -2223,6 +2266,7 @@ Options:
22232266 -j, --cores NUM Use NUM cores during main build
22242267 -J, --qt-cores NUM Use NUM cores during Qt build
22252268 -k, --keep-source Don't overwrite the current source tree
2269+ -P, --pr PR Builds the specified pull request. PR is either a PR number, or the URL to the PR on Github
22262270 -r, --repo REPO Set the repository to REPO
22272271 -t, --tag TAG Set the tag to TAG
22282272 -v, --verbose Run a verbose build, showing the full compiler commands
0 commit comments