Explorar el Código

Formalise exa-packaging script

Every time I had to build exa, I copied the files manually and checked to make sure they all had the same name. There’s now a script that does all that stuff for me, so I don’t need to remember to do it anymore.

It also does some things that weren’t being done before, including stripping the binary and listing its linked dependencies to we can tell if something like libhttp_parser has slipped in there (see #194)
Benjamin Sago hace 8 años
padre
commit
414b347ae5
Se han modificado 3 ficheros con 34 adiciones y 6 borrados
  1. 2 0
      .gitignore
  2. 24 2
      Vagrantfile
  3. 8 4
      xtests/run.sh

+ 2 - 0
.gitignore

@@ -1,4 +1,6 @@
 target
+/exa-linux-x86_64
+/exa-linux-x86_64.zip
 
 .vagrant
 ubuntu-xenial-16.04-cloudimg-console.log

+ 24 - 2
Vagrantfile

@@ -21,7 +21,7 @@ Vagrant.configure(2) do |config|
     config.vm.provision :shell, privileged: true, inline: <<-EOF
         set -xe
         apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
-          git cmake curl attr libgit2-dev \
+          git cmake curl attr libgit2-dev zip \
           fish zsh bash bash-completion
     EOF
 
@@ -68,8 +68,30 @@ Vagrant.configure(2) do |config|
 
         echo -e "#!/bin/sh\nbuild-exa && test-exa && run-xtests" > /usr/bin/compile-exa
         ln -sf /usr/bin/compile-exa /usr/bin/c
+
+        echo "#!/bin/bash"                                                      > /usr/bin/package-exa
+        echo "set -e"                                                          >> /usr/bin/package-exa
+        
+        echo 'echo -e "\nCompiling release version of exa..."'                 >> /usr/bin/package-exa
+        echo "cargo build --release --manifest-path /vagrant/Cargo.toml"       >> /usr/bin/package-exa
+        echo "cargo test --release --manifest-path /vagrant/Cargo.toml --lib"  >> /usr/bin/package-exa
+        echo "/vagrant/xtests/run.sh --release"                                >> /usr/bin/package-exa
+        echo "cp /home/ubuntu/target/release/exa /vagrant/exa-linux-x86_64"    >> /usr/bin/package-exa
+        
+        echo 'echo -e "\nStripping binary..."'                                 >> /usr/bin/package-exa
+        echo "strip /vagrant/exa-linux-x86_64"                                 >> /usr/bin/package-exa
+        
+        echo 'echo -e "\nZipping binary..."'                                   >> /usr/bin/package-exa
+        echo "rm -f /vagrant/exa-linux-x86_64.zip"                             >> /usr/bin/package-exa
+        echo "zip /vagrant/exa-linux-x86_64.zip /vagrant/exa-linux-x86_64"     >> /usr/bin/package-exa
+        
+        echo 'echo -e "\nLibraries linked:"'                                   >> /usr/bin/package-exa
+        echo "ldd /vagrant/exa-linux-x86_64"                                   >> /usr/bin/package-exa
+        
+        echo 'echo -e "\nAll done!"'                                           >> /usr/bin/package-exa
+        echo '/vagrant/exa-linux-x86_64 /vagrant/exa-linux-x86_64* -lB'        >> /usr/bin/package-exa
         
-        chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa}
+        chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa,package-exa}
     EOF
 
 

+ 8 - 4
xtests/run.sh

@@ -2,12 +2,15 @@
 set +xe
 
 
-# The exa binary
-exa_binary="$HOME/target/debug/exa"
+# Release mode
+case "$1" in
+  "--release") echo "Testing release exa..."; exa_binary="$HOME/target/release/exa" ;;
+  *)           exa_binary="$HOME/target/debug/exa" ;;
+esac
 
 if [ ! -f "$exa_binary" ]; then
   echo "exa binary ($exa_binary) does not exist"
-  echo -e "create it first with \033[1;32mbuild-exa\033[0m or \033[1;32mb\033[0m"
+  if [ "$1" != "--release" ]; then echo -e "create it first with \033[1;32mbuild-exa\033[0m or \033[1;32mb\033[0m"; fi
   exit 1
 fi
 
@@ -150,7 +153,8 @@ env LANG=ja_JP.UTF-8  $exa $testcases/dates -l | diff -q - $results/dates_jp  ||
 # Paths and directories
 # These directories are created in the VM user’s home directory (the default
 # location) when a Cargo build is done.
-(cd; $exa -1d target target/debug target/debug/build | diff -q - $results/dir_paths) || exit 1
+(cd; mkdir -p target/debug/build
+     $exa -1d target target/debug target/debug/build | diff -q - $results/dir_paths) || exit 1
      $exa -1d . .. /                                 | diff -q - $results/dirs       || exit 1