From 059d2099e8dfc3e385301e63c50406c32c458214 Mon Sep 17 00:00:00 2001 From: Lee Morgan Date: Wed, 16 Dec 2015 10:14:29 +0000 Subject: [PATCH] Added Emscripten install to dali-env Change-Id: I57b707094bf3a8fbf11bcd0523d5a8f2fe3662e8 --- README | 56 ++++++++++++++++++++++- build/scripts/dali_env | 119 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 166 insertions(+), 9 deletions(-) diff --git a/README b/README index f10e0d2..fa9e31d 100644 --- a/README +++ b/README @@ -10,8 +10,9 @@ T.O.C. 2.3. Building the Repository 2.4. Build target options 2.5. Building and executing test cases - - + 3. Building DALi as Javascript using Emscripten + 3.1. Creating a DALi Environment for Emscripten Javascript builds + 3.2. Building the repository as Javascript using Emscripten 1. GBS Builds ============= @@ -62,6 +63,7 @@ Next source these variables: You will have to source these variables every time you open up a new terminal (or you can add to .bashrc if you prefer). + 2.3. Building the Repository ---------------------------- @@ -75,6 +77,7 @@ Then run the following commands: ./configure --prefix=$DESKTOP_PREFIX make install -j8 + 2.4. Build target options ------------------------- @@ -96,3 +99,52 @@ Add to the gbs build line: --define "%target_gles_version X" See the README.md in dali-core/automated-tests. + +3. Building DALi as Javascript using Emscripten +----------------------------------------------- + + +3.1. Environment for Emscripten Javascript builds +-------------------------------------------------- + +To build the Javascript version of DALi, the Emscripten SDK is required. +Installation of this is built in to the main dali_env script. + +First create a directory for the environment: + +# mkdir -p ~/dali-env-emscripten + +Now run the dali_env script. This will download and build the Emscripten SDK, which may take several minutes. +The script may ask for your password as it will need to install any package prerequisites. +Note the "-e" option for Emscripten. + +# cd ~/dali-env-emscripten +# PATH-TO-DALI-CORE/build/scripts/dali_env -c -e + +Create the setenv script. A new section for Emscripten will be created at the top. + +# ./dali-env/dali-env -s > setenv + +Run the setenv script to setup environment variables. + +# . ./setenv + +Warning: As of 19/01/2015 with a userID > 6 digits there was a bug in llvm that caused +the build to fail. So I've used the incoming branches of the emscripten sdk and not latest. + + +3.2. Building the repository as Javascript using Emscripten +----------------------------------------------------------- + +Clean the build first: + +# cd ./dali-core/build/tizen +# git clean -dxf +# autoreconf --install + +Use llvm's drop in replacements for configure & make: + +# emconfigure ./configure --verbose --prefix=$DESKTOP_PREFIX --enable-emscripten=yes --enable-debug=yes --enable-profile=UBUNTU --enable-gles=20 +# emmake make install -j8 + + diff --git a/build/scripts/dali_env b/build/scripts/dali_env index d3ba046..bb9db7c 100755 --- a/build/scripts/dali_env +++ b/build/scripts/dali_env @@ -47,7 +47,18 @@ my @system_packages = ( "libharfbuzz-dev", "doxygen", "lcov", - "libcurl4-gnutls-dev" + "libcurl4-gnutls-dev", +); + +my @emscripten_system_packages = ( + "gnome-common", + "curl", + "tar", + "build-essential", + "cmake", + "nodejs", + "default-jre", + "python2.7" ); # Some packages like require building from source @@ -62,7 +73,11 @@ 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" => "emscripten", + "portable" => "https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz" + } ); ### Detect any http proxy, part of v8 installation requires this information @@ -129,17 +144,20 @@ else } } -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 $emscripten_path = "$root_path/emsdk_portable"; my $opt_create=0; my $opt_setenv=0; my $opt_help=0; my $opt_man=0; +my $opt_emscripten=0; GetOptions("create" => \$opt_create, "setenv" => \$opt_setenv, + "emscripten" => \$opt_emscripten, "help" => \$opt_help, "man" => \$opt_man) or pod2usage(2); @@ -175,7 +193,25 @@ sub in_dali_env sub create_setenv { + if( ( -d $emscripten_path ) || $opt_emscripten ) + { + print <<"EOF"; +# +# Emscripten environment +# - which brazenly overwrites PATH so we set this first +# - NB: If you change the tools within emsdk then you'll need to recreate this file +# + +EOF + my $emsdk_env_file = $emscripten_path . '/emsdk_set_env.sh'; + open(FILE, $emsdk_env_file) or die "Can't read file enscripten env file" . $emsdk_env_file; + my @emsdk_env = ; + close (FILE); + print @emsdk_env; + } + 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 # \$ $install_path/bin/dali_env -s > setenv @@ -206,7 +242,7 @@ sub check_system_package if($x[0] ne "ii") { print "Attempting to install $package\n"; - system("sudo apt-get -y install $package"); + system("sudo apt-get -y --force-yes install $package"); } } } @@ -216,6 +252,12 @@ sub check_system_packages print "Checking for required system packages (may require sudo password)\n"; check_system_package(@system_packages); + + if($opt_emscripten) + { + check_system_package(@emscripten_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) @@ -245,6 +287,10 @@ sub check_source_packages { install_v8( $pkgref ); } + elsif($pkg eq "emscripten" && $opt_emscripten) + { + install_emscripten( $pkgref ); + } } } @@ -363,7 +409,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"); #### @@ -527,6 +573,61 @@ END } +################################################################################ +# +# install the latest emscripten in a portable directory +# +################################################################################ +sub install_emscripten +{ + my $info = $_[0]; + my $ret; + print( "Checking if Emscripten is up to date\n"); + + my $portable = $info->{"portable"}; + + my $current_dir = getcwd(); + + print( "\n"); + print( "Installing or updating Emscripten.\n"); + print( ".....You may need a cup of tea.\n"); + print( ".......... In fact, take the afternoon off.\n"); + print( "\n"); + + if(-e $emscripten_path) + { + chdir( $emscripten_path ); + } + else + { + chdir( $root_path ); + + system("curl -O " . $portable) == 0 + or die "curl failed with error $?. :" . $portable; + + my($filename, $dirs, $suffix) = fileparse($portable); + + system("tar -xvf " . $filename . $suffix) == 0 + or die "tar unpack failed (nb tar.gz is the presumed downloaded format):" . $filename . $suffix; + + system("rm " . $filename . $suffix) == 0 + or die "Cannot remove emsdk portable tar file:" . $filename . $suffix; + + chdir( $emscripten_path ); + } + + system("./emsdk update") == 0 + or die "Cannot run emsdk? Did the install fail?"; + + system("./emsdk install latest"); + system("./emsdk activate latest"); + system("bash -c \"source ./emsdk_env.sh\""); # emsdk uses popd ie expects bash + + system("emsdk list"); + + chdir($current_dir); +} + ################################################################################ # MAIN @@ -601,6 +702,10 @@ Create a DALi environment directory in the current directory. Display environment variables to setup. +=item B<-e|--emscripten> + +Include emscripten (use with -c to install with emscripten or -s to setup env vars with emscripten). + =item B<-h|--help> Display this help -- 2.7.4