Add hostarch information for build configuration
authorChan Lee <chan45.lee@samsung.com>
Fri, 19 Aug 2016 03:45:11 +0000 (12:45 +0900)
committerSoonKyu Park <sk7.park@samsung.com>
Mon, 26 Sep 2016 01:37:53 +0000 (10:37 +0900)
In a few cases, hostarch information is needed as below,
  1. There are some packages to be installed according to host archtecture
  2. Some config need to be defined each host archtecture

Change-Id: I3409a1c51069ee60f81b46f06d3f99a74e6df452
Signed-off-by: Chan Lee <chan45.lee@samsung.com>
Build.pm
Build/Rpm.pm

index 33b0be6bd0c92a2f02debf193d0d8e1129d8088b..4277c4653e0405180a4a852a2b4d44768c75659c 100644 (file)
--- a/Build.pm
+++ b/Build.pm
@@ -173,11 +173,18 @@ sub read_config_dist {
   return $cf;
 }
 
+sub get_hostarch {
+       my $hostarch = `uname -m` || 'i586';
+       return $hostarch;
+}
+
 sub read_config {
   my ($arch, $cfile) = @_;
   my @macros = split("\n", $std_macros.$extra_macros);
   push @macros, "%define _target_cpu $arch";
   push @macros, "%define _target_os linux";
+  my $hostarch = get_hostarch();
+  push @macros, "%define hostarch $hostarch";
   my $config = {'macros' => \@macros, 'arch' => $arch};
   my @config;
   if (ref($cfile)) {
index d9c6028b59f3de29bca15b741488e8e0fa8c8a87..47cb9e7053e9742f7555f900f9ff7b25e144f352 100644 (file)
@@ -436,6 +436,20 @@ reexpand:
       $hasif = 1;
       next;
     }
+    if ($line =~ /^\s*%ifhostarch(.*)$/) {
+      my $hostarch = $macros{'hostarch'} || 'unknown';
+      my @hostarchs = grep {$_ eq $hostarch} split(/\s+/, $1);
+      $skip = 1 if !@hostarchs;
+      $hasif = 1;
+      next;
+    }
+    if ($line =~ /^\s*%ifnhostarch(.*)$/) {
+      my $hostarch = $macros{'hostarch'} || 'unknown';
+      my @hostarchs = grep {$_ eq $hostarch} split(/\s+/, $1);
+      $skip = 1 if @hostarchs;
+      $hasif = 1;
+      next;
+    }
     if ($line =~ /^\s*%ifos(.*)$/) {
       my $os = $macros{'_target_os'} || 'unknown';
       my @oss = grep {$_ eq $os} split(/\s+/, $1);