(dali_env) Added option to install USD & its dependencies 24/318524/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 1 Oct 2024 12:27:30 +0000 (13:27 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 1 Oct 2024 15:47:47 +0000 (16:47 +0100)
Change-Id: Ia4b4d4ffd599f48d32e53f81db366a5cfb27c656

build/scripts/dali_env

index 8ff18c6a2e13f745865e22cbb685685c54a62c90..be037ade93a130ccd574a2cb226513a7efcac2fa 100755 (executable)
@@ -165,7 +165,7 @@ my $opt_help=0;
 my $opt_man=0;
 my $opt_vk_version="1.3.280.1";
 my $opt_vulkan=undef;
-my $VULKAN_ENV="";
+my $opt_usd=0;
 
 GetOptions("create"     => \$opt_create,
            "envfile=s"  => \$opt_envfile,
@@ -173,6 +173,7 @@ GetOptions("create"     => \$opt_create,
            "setenv"     => \$opt_setenv,
            "help"       => \$opt_help,
            "vulkan:s"   => \$opt_vulkan,
+           "usd"        => \$opt_usd,
            "man"        => \$opt_man) or pod2usage(2);
 
 pod2usage(1) if $opt_help;
@@ -293,8 +294,23 @@ EOF
 }
 
 ################################################################################
-sub vulkan_env
+sub download_archive
 {
+    my ($archive, $url, $download_info) = @_;
+
+    # Avoid excessive downloading of the same file
+    if(! -e "/tmp/$archive")
+    {
+        print "Downloading $download_info\nfrom: $url\n";
+        system('wget','-P','/tmp',$url);
+        die "Can't download archive" if(! -e "/tmp/$archive");
+    }
+}
+
+sub untar_archive
+{
+    my $archive=shift;
+    system('tar','-xf',"/tmp/$archive", '--checkpoint=5000', '--checkpoint-action=ttyout=.');
 }
 
 sub install_vulkan
@@ -303,20 +319,13 @@ sub install_vulkan
     {
         my $archive="vulkansdk-linux-x86_64-${opt_vk_version}.tar.xz";
         my $url="https://sdk.lunarg.com/sdk/download/${opt_vk_version}/linux/$archive";
-
-        # Avoid excessive downloading of the same file
-        if(! -e "/tmp/$archive")
-        {
-            print "Downloading Vulkan SDK version ${opt_vk_version}\nfrom: $url\n";
-            system('wget','-P','/tmp',$url);
-            die "Can't download archive" if(! -e "/tmp/$archive");
-        }
+        download_archive($archive, $url, "Vulkan SDK version ${opt_vk_version}");
 
         my $vulkan_install_path="$root_path/vulkan";
-        print "Unpacking archive\n";
+        print "Unpacking vulkan archive\n";
         mkpath($vulkan_install_path);
         chdir($vulkan_install_path);
-        system('tar','-xf',"/tmp/$archive", '--checkpoint=5000', '--checkpoint-action=ttyout=.');
+        untar_archive($archive);
         print("\n");
         chdir("$root_path/..");
 
@@ -373,6 +382,84 @@ EOF
     }
 }
 
+sub install_usd
+{
+    if($opt_usd)
+    {
+        my $boost_archive="boost-1.84.0.tar.gz";
+        my $boost_url="https://github.com/boostorg/boost/releases/download/boost-1.84.0/$boost_archive";
+        download_archive($boost_archive, $boost_url, "Boost");
+
+        my $tbb_archive="2019_U9.tar.gz";
+        my $tbb_url="https://github.com/oneapi-src/oneTBB/archive/refs/tags/$tbb_archive";
+        download_archive($tbb_archive, $tbb_url, "LibTBB");
+
+        my $openusd_archive="32-bit-arm-and-tizen-support.tar.gz";
+        my $openusd_url="https://github.com/dalihub/OpenUSD/archive/refs/tags/$openusd_archive";
+        download_archive($openusd_archive, $openusd_url, "OpenUSD");
+
+        my $usd_install_path=$install_path;
+        my $usd_source_path="$src_path/usd";
+
+        print "Unpacking Boost, TBB & OpenUSD archives\n";
+        mkpath($usd_source_path);
+        chdir($usd_source_path);
+        untar_archive($boost_archive);
+        untar_archive($tbb_archive);
+        untar_archive($openusd_archive);
+
+        mkpath("$usd_install_path/lib");
+        mkpath("$usd_install_path/include");
+
+        my $boost_source_path="$usd_source_path/boost-1.84.0";
+        print "Building Boost\n";
+        chdir("$boost_source_path");
+        system('cmake',"-DCMAKE_INSTALL_PREFIX=$usd_install_path", '.');
+        system('make','-j8','install');
+
+        my $tbb_source_path="$usd_source_path/oneTBB-2019_U9";
+        print "Building TBB\n";
+        chdir("$tbb_source_path");
+        system('make','-j8');
+        my $tbbBuildFolder=`make info | grep tbb_build_prefix | cut -d= -f 2`;
+        chomp($tbbBuildFolder);
+        $tbbBuildFolder=$tbbBuildFolder . "_release";
+        print "$tbbBuildFolder Hello";
+        system("install -m 644 ./build/$tbbBuildFolder/*.so* $usd_install_path/lib/");
+        system('cp','-rf','include/tbb',"$usd_install_path/include/");
+
+        my $openusd_source_path="$usd_source_path/OpenUSD-32-bit-arm-and-tizen-support";
+        print "Building USD\n";
+        chdir("$openusd_source_path");
+        system('cmake',
+               '-DPXR_ENABLE_PYTHON_SUPPORT=OFF',
+               '-DPXR_ENABLE_PTEX_SUPPORT=OFF',
+               '-DPXR_ENABLE_OPENVDB_SUPPORT=OFF',
+               '-DPXR_ENABLE_HDF5_SUPPORT=OFF',
+               '-DPXR_ENABLE_MATERIALX_SUPPORT=OFF',
+               '-DPXR_BUILD_IMAGING=OFF',
+               '-DPXR_BUILD_USD_IMAGING=OFF',
+               '-DPXR_BUILD_USDVIEW=OFF',
+               '-DPXR_BUILD_DOCUMENTATION=OFF',
+               '-DPXR_BUILD_HTML_DOCUMENTATION=OFF',
+               '-DPXR_BUILD_PYTHON_DOCUMENTATION=OFF',
+               '-DPXR_BUILD_TESTS=OFF',
+               '-DPXR_BUILD_EXAMPLES=OFF',
+               '-DPXR_BUILD_TUTORIALS=OFF',
+               '-DPXR_BUILD_USD_TOOLS=OFF',
+               '-DPXR_BUILD_MAYAPY_TESTS=OFF',
+               '-DPXR_BUILD_ANIMX_TESTS=OFF',
+               "-DTBB_ROOT_DIR=$usd_install_path",
+               "-DBOOST_ROOT=$usd_install_path",
+               "-DCMAKE_INSTALL_PREFIX=$usd_install_path",
+               '.'
+              );
+        system('make','-j8','install');
+
+        print("\n");
+        chdir("$root_path/..");
+    }
+}
 
 sub check_system_package
 {
@@ -755,6 +842,7 @@ if($opt_create)
     check_source_packages();
 
     install_vulkan();
+    install_usd();
     create_setenv();
 }
 elsif($opt_setenv)
@@ -811,6 +899,10 @@ Install the Vulkan SDK (By default, uses 1.3.280.1) with the optional version
 number. Adds several .pc files into dali-env/opt/lib/pkg-config directory,
 and requires a new environment file to be written.
 
+=item B<-u|--usd>
+
+Installs the OpenUSD library and its dependencies.
+
 =item B<-h|--help>
 
 Display this help