From fdfd3d2ccce208d7ddcc505dadbcf0b531e001bb Mon Sep 17 00:00:00 2001
From: an7s <an7s@git.zephyr-software.com>
Date: Sun, 5 Jul 2015 18:28:16 +0000
Subject: [PATCH] fixed build, compile both 32 & 64 bit on 64 bit platforms

Former-commit-id: 6f04ac6ad2376421d8e764cd6d62687dfb141452
---
 SConscript              | 36 ++++++++++++++++++++++++++++--------
 SConstruct              |  6 +++---
 appfw/SConscript        |  6 +++---
 appfw/src/SConscript.32 | 21 ---------------------
 appfw/src/SConscript.64 | 22 ----------------------
 5 files changed, 34 insertions(+), 57 deletions(-)

diff --git a/SConscript b/SConscript
index c8a92140b..7cd2f6bb0 100644
--- a/SConscript
+++ b/SConscript
@@ -6,28 +6,47 @@ Import('env')
 
 if env.GetOption('clean'):
     if os.path.exists(os.environ['SECURITY_TRANSFORMS_HOME']+"/third_party/ELFIO"):
-	print 'Removing third_party/ELFIO'
+        print 'Removing third_party/ELFIO'
     	shutil.rmtree(os.environ['SECURITY_TRANSFORMS_HOME']+"/third_party/ELFIO")
+    if os.path.exists(os.environ['SECURITY_TRANSFORMS_HOME']+"/third_party/SQLITE3"):
+        print 'Removing third_party/SQLITE3'
+    	shutil.rmtree(os.environ['SECURITY_TRANSFORMS_HOME']+"/third_party/SQLITE3")
     if os.path.exists(os.environ['SECURITY_TRANSFORMS_HOME']+"/include/elfio"):
-	print 'Removing include/elfio'
+        print 'Removing include/elfio'
     	shutil.rmtree(os.environ['SECURITY_TRANSFORMS_HOME']+"/include/elfio")
     if os.path.exists(os.environ['SECURITY_TRANSFORMS_HOME']+"/include/targ-config.h"):
-	print 'Removing include/elfio'
+        print 'Removing include/targ-config.h'
     	os.remove(os.environ['SECURITY_TRANSFORMS_HOME']+"/include/targ-config.h")
 else:
     ELFIO_DIR=os.environ['SECURITY_TRANSFORMS_HOME']+"/third_party/ELFIO/"
     if not os.path.exists(ELFIO_DIR):
         os.makedirs(ELFIO_DIR)     # make directory 
         tgz=tarfile.open(os.environ['SECURITY_TRANSFORMS_HOME']+"/third_party/elfio-2.2.tar.gz", "r:gz")
-	print 'Extracting elfio tarball'
-	tgz.list(verbose=False)
+        print 'Extracting elfio tarball'
+        tgz.list(verbose=False)
         tgz.extractall(ELFIO_DIR)
     	shutil.copytree(ELFIO_DIR+"elfio-2.2/elfio", os.environ['SECURITY_TRANSFORMS_HOME']+"/include/elfio")
-	shutil.copy(os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'],"third_party","elfio.hpp"), 
+        shutil.copy(os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'],"third_party","elfio.hpp"), 
 		    os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'],"include","elfio","elfio.hpp"))
     else:
         assert os.path.isdir(ELFIO_DIR)
 
+    # SQLITE3
+    SQLITE3_DIR=os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'third_party/SQLITE3')
+    if not os.path.exists(SQLITE3_DIR):
+        os.makedirs(SQLITE3_DIR)     # make directory 
+        tgz=tarfile.open(os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'third_party/sqlite-autoconf-3071300.tar.gz'), "r:gz")
+        print 'Extracting needed files from sqlite3 tarball'
+        tgz.list(verbose=False)
+        tgz.extract('sqlite-autoconf-3071300/sqlite3.h', SQLITE3_DIR)
+        tgz.extract('sqlite-autoconf-3071300/sqlite3.c', SQLITE3_DIR)
+		# copy sqlite3.h
+        source_dir = os.path.join(SQLITE3_DIR, 'sqlite-autoconf-3071300') 
+        target_dir = os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'appfw', 'src')
+        shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.abspath(os.path.join(target_dir, 'sqlite3.h')))
+    else:
+        assert os.path.isdir(SQLITE3_DIR)
+
     # check/install targ-config.h
     if not os.path.isfile(os.environ['SECURITY_TRANSFORMS_HOME']+"/include/targ-config.h"):
  	(sysname, nodename, release, version, machine)=os.uname()
@@ -48,5 +67,6 @@ SConscript("tools/SConscript", variant_dir='scons_build/tools')
 
 build_appfw=ARGUMENTS.get("build_appfw", None)
 if build_appfw is None or int(build_appfw)==1:
-	SConscript("appfw/SConscript", variant_dir='scons_build/appfw')
-#if ARGUMENTS.get("build_appfw", None) is None or int(env['build_appfw'])==1:
+#    SConscript("appfw/src/SConscript", variant_dir='scons_build/appfw')
+    SConscript("appfw/src/SConscript.64", variant_dir='scons_build/appfw.64')
+    SConscript("appfw/src/SConscript.32", variant_dir='scons_build/appfw.32')
diff --git a/SConstruct b/SConstruct
index 80bdf75fb..0b223f575 100644
--- a/SConstruct
+++ b/SConstruct
@@ -13,11 +13,11 @@ env.Replace(LINKFLAGS="-fPIC -w ")
 env.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME'])
 env.Replace(do_64bit_build=ARGUMENTS.get("do_64bit_build",None))
 env.Replace(debug=ARGUMENTS.get("debug",0))
-#env.Replace(build_appfw=ARGUMENTS.get("build_appfw", None))
+env.Replace(build_appfw=ARGUMENTS.get("build_appfw", None))
 
 # by default, turn on build of appfw
-#if env['build_appfw'] is None:
-#	env['build_appfw'] = 1
+if env['build_appfw'] is None:
+	env['build_appfw'] = 1
 
 if int(env['debug']) == 1:
         print "Setting debug mode"
diff --git a/appfw/SConscript b/appfw/SConscript
index 5c6d91974..e10a2cbd2 100644
--- a/appfw/SConscript
+++ b/appfw/SConscript
@@ -1,7 +1,7 @@
 import os
+import shutil
 
 Import('env')
 
-SConscript("src/SConstruct")
-
-#SConscript("test/SConscript")
+SConscript("src/SConscript.64", variant_dir='build64')
+SConscript("src/SConscript.32", variant_dir='build32')
diff --git a/appfw/src/SConscript.32 b/appfw/src/SConscript.32
index bf7725f55..97d4367d3 100644
--- a/appfw/src/SConscript.32
+++ b/appfw/src/SConscript.32
@@ -20,8 +20,6 @@ env.Replace(CCFLAGS="-m32")
 
 SQLITE3_DIR=os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'third_party/SQLITE3')
 
-print 'i am in cwd: ', os.getcwd()
-
 if env.GetOption('clean'):
     print 'option clean is turned on'
     if os.path.exists(SQLITE3_DIR):
@@ -33,14 +31,6 @@ if env.GetOption('clean'):
     if os.path.exists('combined_sqlite3.c'):
         os.remove('combined_sqlite3.c')
 else:
-    if not os.path.exists(SQLITE3_DIR):
-        os.makedirs(SQLITE3_DIR)     # make directory 
-        tgz=tarfile.open(os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'third_party/sqlite-autoconf-3071300.tar.gz'), "r:gz")
-        print 'Extracting needed files from sqlite3 tarball'
-        tgz.list(verbose=False)
-        tgz.extract('sqlite-autoconf-3071300/sqlite3.h', SQLITE3_DIR)
-        tgz.extract('sqlite-autoconf-3071300/sqlite3.c', SQLITE3_DIR)
-
     assert os.path.isdir(SQLITE3_DIR)
 
     source_dir = os.path.join(SQLITE3_DIR, 'sqlite-autoconf-3071300') 
@@ -48,14 +38,6 @@ else:
     shutil.copy(os.path.join(source_dir, 'sqlite3.c'), os.path.join(target_dir, 'appfw_sqlite3.c'))
     shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.join(target_dir, 'appfw_sqlite3.h'))
 
-    print 'Copying sqlite3.h into: ' + os.path.join(target_dir, 'sqlite3.h')
-    shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.join(target_dir, 'sqlite3.h'))
-    print 'Copying sqlite3.h into: ' + os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h'))
-    shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h')))
-
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h')))
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, 'sqlite3.h')))
-
     # need to do the sed replacement:  sqlite3.[ch] --> appfw_sqlite3.[ch]
     substitute_in_file(os.path.join(target_dir,'appfw_sqlite3.c'), 'sqlite3', 'appfw_sqlite3')
     substitute_in_file(os.path.join(target_dir,'appfw_sqlite3.h'), 'sqlite3', 'appfw_sqlite3')
@@ -67,9 +49,6 @@ else:
        for line in fileinput.input(files=('appfw_sqlite3.c', sqlfw_c)):
            fout.write(line)
 
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h')))
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, 'sqlite3.h')))
-
 libname="appfw"
 
 files_c = '''
diff --git a/appfw/src/SConscript.64 b/appfw/src/SConscript.64
index 989a0e11f..36571f788 100644
--- a/appfw/src/SConscript.64
+++ b/appfw/src/SConscript.64
@@ -20,10 +20,7 @@ env.Replace(INSTALL_PATH_PREFIX="$SECURITY_TRANSFORMS_HOME/appfw/lib/64")
 
 SQLITE3_DIR=os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'third_party/SQLITE3')
 
-print 'i am in cwd: ', os.getcwd()
-
 if env.GetOption('clean'):
-    print 'option clean is turned on'
     if os.path.exists(SQLITE3_DIR):
         shutil.rmtree(SQLITE3_DIR)
     if os.path.exists('appfw_sqlite3.c'):
@@ -33,14 +30,6 @@ if env.GetOption('clean'):
     if os.path.exists('combined_sqlite3.c'):
         os.remove('combined_sqlite3.c')
 else:
-    if not os.path.exists(SQLITE3_DIR):
-        os.makedirs(SQLITE3_DIR)     # make directory 
-        tgz=tarfile.open(os.path.join(os.environ['SECURITY_TRANSFORMS_HOME'], 'third_party/sqlite-autoconf-3071300.tar.gz'), "r:gz")
-        print 'Extracting needed files from sqlite3 tarball'
-        tgz.list(verbose=False)
-        tgz.extract('sqlite-autoconf-3071300/sqlite3.h', SQLITE3_DIR)
-        tgz.extract('sqlite-autoconf-3071300/sqlite3.c', SQLITE3_DIR)
-
     assert os.path.isdir(SQLITE3_DIR)
 
     source_dir = os.path.join(SQLITE3_DIR, 'sqlite-autoconf-3071300') 
@@ -48,14 +37,6 @@ else:
     shutil.copy(os.path.join(source_dir, 'sqlite3.c'), os.path.join(target_dir, 'appfw_sqlite3.c'))
     shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.join(target_dir, 'appfw_sqlite3.h'))
 
-    print 'Copying sqlite3.h into: ' + os.path.join(target_dir, 'sqlite3.h')
-    shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.join(target_dir, 'sqlite3.h'))
-    print 'Copying sqlite3.h into: ' + os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h'))
-    shutil.copy(os.path.join(source_dir, 'sqlite3.h'), os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h')))
-
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h')))
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, 'sqlite3.h')))
-
     # need to do the sed replacement:  sqlite3.[ch] --> appfw_sqlite3.[ch]
     substitute_in_file(os.path.join(target_dir,'appfw_sqlite3.c'), 'sqlite3', 'appfw_sqlite3')
     substitute_in_file(os.path.join(target_dir,'appfw_sqlite3.h'), 'sqlite3', 'appfw_sqlite3')
@@ -67,9 +48,6 @@ else:
        for line in fileinput.input(files=('appfw_sqlite3.c', sqlfw_c)):
            fout.write(line)
 
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, '..', 'sqlite3.h')))
-    assert os.path.exists(os.path.abspath(os.path.join(target_dir, 'sqlite3.h')))
-
 libname="appfw"
 
 files_c = '''
-- 
GitLab