@@ -43,6 +43,7 @@ do_polly="yes"
4343BuildDir=" ` pwd` " 
4444ExtraConfigureFlags=" " 
4545ExportBranch=" " 
46+ git_ref=" " 
4647
4748function  usage()  {
4849    echo  " usage: ` basename $0 ` " 
@@ -60,8 +61,7 @@ function usage() {
6061    echo  "  -use-gzip            Use gzip instead of xz." 
6162    echo  "  -use-ninja           Use ninja instead of make/gmake." 
6263    echo  "  -configure-flags FLAGS  Extra flags to pass to the configure step." 
63-     echo  "  -svn-path DIR        Use the specified DIR instead of a release." 
64-     echo  "                       For example -svn-path trunk or -svn-path branches/release_37" 
64+     echo  "  -git-ref sha         Use the specified git ref for testing instead of a release." 
6565    echo  "  -no-rt               Disable check-out & build Compiler-RT" 
6666    echo  "  -no-libs             Disable check-out & build libcxx/libcxxabi/libunwind" 
6767    echo  "  -no-libcxxabi        Disable check-out & build libcxxabi" 
@@ -88,13 +88,14 @@ while [ $# -gt 0 ]; do
8888        -final | --final )
8989            RC=final
9090            ;;
91-         -svn-path  | --svn-path  )
91+         -git-ref  | --git-ref  )
9292            shift 
9393            Release=" test" 
9494            Release_no_dot=" test" 
9595            ExportBranch=" $1 " 
9696            RC=" ` echo $ExportBranch  |  sed -e ' s,/,_,g' ` " 
97-             echo  " WARNING: Using the branch $ExportBranch  instead of a release tag" 
97+             git_ref=" $1 " 
98+             echo  " WARNING: Using the ref $git_ref  instead of a release tag" 
9899            echo  "          This is intended to aid new packagers in trialing " 
99100            echo  "          builds without requiring a tag to be created first" 
100101            ;;
@@ -196,6 +197,17 @@ if [ -z "$Triple" ]; then
196197    exit  1
197198fi 
198199
200+ if  [ " $Release " !=  " test" ;  then 
201+   if  [ -n  " $git_ref " ;  then 
202+     echo  " error: can't specify both -release and -git-ref" 
203+     exit  1
204+   fi 
205+   git_ref=llvmorg-$Release 
206+   if  [ " $RC " !=  " final" ;  then 
207+     git_ref=" $git_ref -$RC " 
208+   fi 
209+ fi 
210+ 
199211#  Figure out how many make processes to run.
200212if  [ -z  " $NumJobs " ;  then 
201213    NumJobs=` sysctl -n hw.activecpu 2>  /dev/null ||  true` 
@@ -211,7 +223,7 @@ if [ -z "$NumJobs" ]; then
211223fi 
212224
213225#  Projects list
214- projects=" llvm cfe  clang-tools-extra" 
226+ projects=" llvm clang  clang-tools-extra" 
215227if  [ $do_rt  =  " yes" ;  then 
216228  projects=" $projects  compiler-rt" 
217229fi 
285297
286298check_program_exists ${MAKE} 
287299
288- #  Make sure that the URLs are valid.
289- function  check_valid_urls()  {
290-     for  proj  in  $projects  ;  do 
291-         echo  " # Validating $proj  SVN URL" 
292- 
293-         if  !  svn ls $Base_url /$proj /$ExportBranch  >  /dev/null 2>&1  ;  then 
294-             echo  " $proj  does not have a $ExportBranch  branch/tag!" 
295-             exit  1
296-         fi 
297-     done 
298- }
299- 
300300#  Export sources to the build directory.
301301function  export_sources()  {
302-     check_valid_urls
303- 
304-     for  proj  in  $projects  ;  do 
305-         case  $proj  in 
306-         llvm)
307-             projsrc=$proj .src
308-             ;;
309-         cfe)
310-             projsrc=llvm.src/tools/clang
311-             ;;
312-         lld|lldb|polly)
313-             projsrc=llvm.src/tools/$proj 
314-             ;;
315-         clang-tools-extra)
316-             projsrc=llvm.src/tools/clang/tools/extra
317-             ;;
318-         compiler-rt|libcxx|libcxxabi|libunwind|openmp)
319-             projsrc=llvm.src/projects/$proj 
320-             ;;
321-         test-suite)
322-             projsrc=$proj .src
323-             ;;
324-         * )
325-             echo  " error: unknown project $proj " 
326-             exit  1
327-             ;;
328-         esac 
329- 
330-         if  [ -d  $projsrc  ];  then 
331-           echo  " # Reusing $proj  $Release -$RC  sources in $projsrc " 
332-           continue 
333-         fi 
334-         echo  " # Exporting $proj  $Release -$RC  sources to $projsrc " 
335-         if  !  svn export  -q $Base_url /$proj /$ExportBranch  $projsrc  ;  then 
336-             echo  " error: failed to export $proj  project" 
337-             exit  1
338-         fi 
339-     done 
302+   SrcDir=$BuildDir /llvm-project
303+   mkdir -p $SrcDir 
304+   echo  " # Using git ref: $git_ref " 
305+ 
306+   #  GitHub allows you to download a tarball of any commit using the URL:
307+   #  https://github.com/$organization/$repo/archive/$ref.tar.gz
308+   curl -L https://github.com/llvm/llvm-project/archive/$git_ref .tar.gz |  \
309+     tar -C $SrcDir  --strip-components=1 -xzf -
310+ 
311+   if  [ " $do_test_suite " =  " yes" ;  then 
312+     TestSuiteSrcDir=$BuildDir /llvm-test-suite
313+     mkdir -p $TestSuiteSrcDir 
314+ 
315+     #  We can only use named refs, like branches and tags, that exist in
316+     #  both the llvm-project and test-suite repos if we want to run the
317+     #  test suite.
318+     #  If the test-suite fails to download assume we are using a ref that
319+     #  doesn't exist in the test suite and disable it.
320+     set  +e
321+     curl -L https://github.com/llvm/test-suite/archive/$git_ref .tar.gz |  \
322+       tar -C $TestSuiteSrcDir  --strip-components=1 -xzf -
323+     if  [ $?  -ne  -0 ];  then 
324+       echo  " $git_ref  not found in test-suite repo, test-suite disabled." 
325+       do_test_suite=" no" 
326+     fi 
327+     set  -e
328+   fi 
340329
341-      cd  $BuildDir 
330+   cd  $BuildDir 
342331}
343332
344333function  configure_llvmCore()  {
@@ -366,6 +355,7 @@ function configure_llvmCore() {
366355            ;;
367356    esac 
368357
358+     project_list=${projects//  / ;} 
369359    echo  " # Using C compiler: $c_compiler " 
370360    echo  " # Using C++ compiler: $cxx_compiler " 
371361
@@ -375,12 +365,14 @@ function configure_llvmCore() {
375365    echo  " #" " $c_compiler " " $cxx_compiler " 
376366        cmake -G " $generator " 
377367        -DCMAKE_BUILD_TYPE=$BuildType  -DLLVM_ENABLE_ASSERTIONS=$Assertions  \
378-         $ExtraConfigureFlags  $BuildDir /llvm.src \
368+         -DLLVM_ENABLE_PROJECTS=" $project_list " 
369+         $ExtraConfigureFlags  $BuildDir /llvm-project/llvm \
379370        2>&1  |  tee $LogDir /llvm.configure-Phase$Phase -$Flavor .log
380371    env CC=" $c_compiler " " $cxx_compiler " 
381372        cmake -G " $generator " 
382373        -DCMAKE_BUILD_TYPE=$BuildType  -DLLVM_ENABLE_ASSERTIONS=$Assertions  \
383-         $ExtraConfigureFlags  $BuildDir /llvm.src \
374+         -DLLVM_ENABLE_PROJECTS=" $project_list " 
375+         $ExtraConfigureFlags  $BuildDir /llvm-project/llvm \
384376        2>&1  |  tee $LogDir /llvm.configure-Phase$Phase -$Flavor .log
385377
386378    cd  $BuildDir 
@@ -491,10 +483,10 @@ if [ $do_test_suite = "yes" ]; then
491483  SandboxDir=" $BuildDir /sandbox" 
492484  Lit=$SandboxDir /bin/lit
493485  TestSuiteBuildDir=" $BuildDir /test-suite-build" 
494-   TestSuiteSrcDir=" $BuildDir /test-suite.src " 
486+   TestSuiteSrcDir=" $BuildDir /llvm- test-suite" 
495487
496488  virtualenv $SandboxDir 
497-   $SandboxDir /bin/python $BuildDir /llvm.src /utils/lit/setup.py install
489+   $SandboxDir /bin/python $BuildDir /llvm-project/llvm /utils/lit/setup.py install
498490  mkdir -p $TestSuiteBuildDir 
499491fi 
500492
0 commit comments