(dali_env) Install the correct package depending on the Ubuntu version
[platform/core/uifw/dali-core.git] / build / scripts / dali_env
index bc56c47..3a952dd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+# Copyright (c) 2021 Samsung Electronics Co., Ltd.
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -37,26 +37,45 @@ my @system_packages = (
     "pkg-config",
     "libtool",
     "ccache",
-    "libboost-dev",
-    "libboost-thread-dev",
-    "libelementary-dev",
     "libexif-dev",
-    "libxml2-dev",
     "libgles2-mesa-dev",
     "libdrm-dev",
     "libgif-dev",
     "libturbojpeg",
+    "libturbojpeg0-dev",
     "libfribidi-dev",
     "libharfbuzz-dev",
+    "libhyphen-dev",
     "doxygen",
     "lcov",
-    "libcurl4-gnutls-dev"
+    "libcurl4-gnutls-dev",
+    "curl",
+    "libssl-dev",
+    "cifs-utils",
+    "libgtest-dev",
+    "libcairo2-dev",
+    "libopencv-dev",
+    "gettext",
+    "libwebp-dev",
 );
 
+my $ubuntu_version = (split(/\s+/, `lsb_release -d`))[2];
+if (${ubuntu_version} > 20)
+{
+    # Add unique packages for 20.04 and above
+    push @system_packages, "libefl-all-dev";
+}
+else
+{
+    # Add unique packages for Ubuntu releases before 20.04
+    push @system_packages, "libelementary-dev";
+}
+
 # Some packages like require building from source
+# v8 is currently disabled until we can get it working without a http proxy being setup
 my @source_pkgs = (
 
-    {"name" => "v8",
+    {"name" => "disabled-v8",
      "force-rebuild" => 0,
      "use_depot_tools" => 1,
      "repo" => "https://chromium.googlesource.com/v8/v8.git",
@@ -64,7 +83,8 @@ my @source_pkgs = (
 
      # original version used with DALi is 3.25.19. 3.32.7 is the latest we can use before
      # upgrading DALi to use  c++0x or c++11
-     "version" => " 3.32.7", "make" => "make -j8 library=shared", "build-mode" =>"debug" }
+     "version" => " 3.32.7", "make" => "make -j8 library=shared", "build-mode" =>"debug" },
+    {"name" => "gtest" },
 );
 
 ### Detect any http proxy, part of v8 installation requires this information
@@ -95,30 +115,45 @@ if($0 !~ m!^/!)
 $exec_path = dirname($exec_path);
 
 my $root_path = getcwd();
+
+# Search for the root dali-env directory
 if($exec_path =~ m!dali-env/opt/bin!)
 {
+    # We are using the installed dali_env script
+
     $root_path = $exec_path;
-    while($root_path !~ m!dali-env$!)
+    while(basename($root_path) ne "dali-env" && $root_path ne "")
     {
         $root_path = dirname($root_path);
     }
 }
-elsif($root_path =~ m!dali-env!)
+elsif($root_path =~ m!dali-env$! or $root_path =~ m!dali-env/!)
 {
-    while($root_path !~ m!dali-env$!)
+    # We are NOT using the installed dali_env script
+    # Find dali-env root from current directory
+
+    while(basename($root_path) ne "dali-env" && $root_path ne "")
     {
         $root_path = dirname($root_path);
     }
 }
 else
 {
-    $new_env = 1;
+    # dali-env root dir should be in the current directory
+
     $root_path .= "/dali-env";
+
+    if(! -e $root_path)
+    {
+      # Creating a new dali-env
+
+      $new_env = 1;
+    }
 }
 
-my $src_path     = "$root_path/src-packages";
-my $sbs_path     = "$root_path/target";
-my $install_path = "$root_path/opt";
+my $src_path         = "$root_path/src-packages";
+my $sbs_path         = "$root_path/target";
+my $install_path     = "$root_path/opt";
 
 my $opt_create=0;
 my $opt_setenv=0;
@@ -163,21 +198,27 @@ sub in_dali_env
 sub create_setenv
 {
     print <<"EOF";
+#
 # To use the desktop libraries, please add the following lines to your .bashrc or
 # create a setenv script from them, e.g. by running this command as follows
-# \$ dali_env -s > setenv
+# \$ $install_path/bin/dali_env -s > setenv
 #
 # You can then source this script by using
 # \$ . setenv
 #
-# Use DESKTOP_PREFIX when running configure in dali/build/tizen:
+# Use DESKTOP_PREFIX when running configure or cmake in dali/build/tizen:
 # \$ CXXFLAGS="-g -O0" ./configure --prefix=\$DESKTOP_PREFIX
+# _OR_
+# \$ CXXFLAGS="-g -O0" cmake -DCMAKE_INSTALL_PREFIX=\$DESKTOP_PREFIX
 
 export DESKTOP_PREFIX=$install_path
 export PATH=$install_path/bin:\$PATH
 export LD_LIBRARY_PATH=$install_path/lib:\$LD_LIBRARY_PATH
 export INCLUDEDIR=$install_path/include
 export PKG_CONFIG_PATH=$install_path/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
+export DOTNET_CLI_TELEMETRY_OPTOUT=1
+export DALI_WINDOW_WIDTH=480
+export DALI_WINDOW_HEIGHT=800
 
 EOF
 }
@@ -189,11 +230,15 @@ sub check_system_package
     my $package;
     foreach $package (@_)
     {
-        my @x=split(/\s+/, `dpkg -l $package|grep $package`);
+        my @x=split(/\s+/, `dpkg -l $package 2> /dev/null|grep $package`);
         if($x[0] ne "ii")
         {
-            print "Attempting to install $package\n";
-            system("sudo apt-get -y install $package");
+            # Check if the package is available to install, exit-code is 0 if the package is found.
+            if(system("apt-cache show $package > /dev/null 2>&1") == 0)
+            {
+                print "Attempting to install $package\n";
+                system("sudo apt-get -y --force-yes install $package");
+            }
         }
     }
 }
@@ -203,6 +248,7 @@ sub check_system_packages
     print "Checking for required system packages (may require sudo password)\n";
 
     check_system_package(@system_packages);
+
     my $gnome_v =`dpkg -l gnome-common| tail -1| sed "s/ \\+/ /g" | cut -d' ' -f 3`;
     my @am = split(/\./, `automake --version | head -1 | cut -f4 -d' '`);
     if($gnome_v =~ /$2.24/ && $am[1]>10)
@@ -232,6 +278,15 @@ sub check_source_packages
         {
             install_v8( $pkgref );
         }
+        elsif ($pkg eq "gtest")
+        {
+            if(! -e "/usr/lib/libgtest.a")
+            {
+                print "Attempting to build $pkg\n";
+                # from https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
+                run_command("cd /usr/src/gtest; sudo cmake CMakeLists.txt; sudo make; sudo cp *.a /usr/lib; cd -;");
+            }
+        }
     }
 }
 
@@ -350,7 +405,7 @@ sub install_v8
 {
     my $v8 = $_[0];
     my $ret;
-    my $v8Version = $v8->{"version"} ;
+    my $v8Version = $v8->{"version"};
     print( "Checking if V8 ". $v8Version. " is installed \n");
 
 ####
@@ -514,7 +569,6 @@ END
 
 }
 
-
 ################################################################################
 #                                       MAIN
 ################################################################################
@@ -529,6 +583,10 @@ if($opt_create)
         die "Already in a dali-env directory\n";
         # Could query if user wants to re-create?
     }
+    elsif(-e $root_path)
+    {
+        die "$root_path already exists\n";
+    }
     elsif(-e $new_root)
     {
         die "A dali-env directory already exists here\n";