aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2012-02-22 13:57:05 -0500
committerGerrit <chrome-bot@google.com>2012-03-07 13:06:17 -0800
commita8d2b777a4600203d377fca0050127ca126e018b (patch)
tree25c39d43669749bb28d2a5f8656f2d3516dcc03c
parentb66113fd7f7ba7972ac46b3e6da050b0af8e71ce (diff)
downloadplatform_external_libbrillo-a8d2b777a4600203d377fca0050127ca126e018b.tar.gz
platform_external_libbrillo-a8d2b777a4600203d377fca0050127ca126e018b.tar.bz2
platform_external_libbrillo-a8d2b777a4600203d377fca0050127ca126e018b.zip
libchromeos: build SLOT-ed shared libraries
This merges the SLOT-ed libchrome into a SLOT-ed shared libchromeos. Now all apps wil link against libchromeos rather than libbase. This allows us to lock things in and track the dependencies. The fallout is that we no longer build a static libchromeos. Similarly for libpolicy, SLOT it and stop building libpolicy.a. BUG=chromium-os:26736 TEST=`FEATURES=test emerge libchromeos` works TEST=build_packages+build_image for x86-alex boots TEST=`cbuildbot arm-generic-full` works TEST=`cbuildbot x86-generic-full` works URL: https://groups.google.com/a/chromium.org/group/chromium-os-dev/browse_thread/thread/75a1fdee269c41e4 Change-Id: Ibccd471f2cde7901f71750a3d67fd8ecb36dab40 Reviewed-on: https://gerrit.chromium.org/gerrit/16763 Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Chris Masone <cmasone@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org>
-rw-r--r--SConstruct149
-rw-r--r--libchromeos.pc5
-rw-r--r--libchromeos.pc.in7
3 files changed, 121 insertions, 40 deletions
diff --git a/SConstruct b/SConstruct
index 5bdf3cd..812b6d7 100644
--- a/SConstruct
+++ b/SConstruct
@@ -8,12 +8,15 @@ import SCons.Util
ROOT = os.environ.get('ROOT', '/')
PKG_CONFIG = os.environ.get('PKG_CONFIG', 'pkg-config')
+BASE_VER = os.environ['BASE_VER']
+libchrome = 'chrome-%s' % BASE_VER
+libchromeos = 'chromeos-%s' % BASE_VER
# Set up an env object that every target below can be based on.
def common_env():
env = Environment(
- CPPPATH = [ '.' ],
- CCFLAGS = [ '-g' ],
+ CPPPATH = [ '.', './chromeos/policy', ],
+ CCFLAGS = [ '-g', ],
)
for key in Split('CC CXX AR RANLIB LD NM CFLAGS CXXFLAGS CCFLAGS LIBPATH'):
@@ -35,45 +38,118 @@ def common_env():
return env
-SOURCES=['chromeos/cryptohome.cc',
- 'chromeos/dbus/abstract_dbus_service.cc',
- 'chromeos/dbus/dbus.cc',
- 'chromeos/dbus/error_constants.cc',
- 'chromeos/process.cc',
- 'chromeos/string.cc',
- 'chromeos/syslog_logging.cc',
- 'chromeos/utility.cc']
+common_pc_libs = 'lib%s' % libchrome
+base_name = 'chromeos'
+base_libs = [
+ {
+ 'name' : 'core',
+ 'sources' : """
+ chromeos/dbus/abstract_dbus_service.cc
+ chromeos/dbus/dbus.cc
+ chromeos/dbus/error_constants.cc
+ chromeos/process.cc
+ chromeos/syslog_logging.cc
+ chromeos/utility.cc
+ """,
+ 'libs' : '',
+ 'pc_libs' : 'dbus-1 glib-2.0 dbus-glib-1 dbus-c++-1 ' + common_pc_libs,
+ },
+ {
+ 'name' : 'cryptohome',
+ 'sources' : """
+ chromeos/cryptohome.cc
+ """,
+ 'libs' : '',
+ 'pc_libs' : 'openssl ' + common_pc_libs,
+ },
+ {
+ 'name' : 'pcre',
+ 'sources' : """
+ chromeos/string.cc
+ """,
+ 'libs' : '',
+ 'pc_libs' : 'libpcrecpp ' + common_pc_libs,
+ },
+]
+
env = common_env()
env.Append(
+ LIBS = ['event'],
CPPPATH = ['../third_party/chrome/files'],
)
+env_test = env.Clone()
+
+all_base_libs = []
+all_pc_libs = ''
+all_libs = []
+all_scons_libs = []
+
+# Build all the shared libraries.
+for lib in base_libs:
+ pc_libs = lib['pc_libs'].replace('${bslot}', BASE_VER)
+ all_pc_libs += ' ' + pc_libs
+
+ libs = Split(lib['libs'].replace('${bslot}', BASE_VER))
+ all_libs += libs
+
+ name = '%s-%s-%s' % (base_name, lib['name'], BASE_VER)
+ all_base_libs += [name]
+ corename = '%s-core-%s' % (base_name, BASE_VER)
+ # Automatically link the sub-libs against the main core lib.
+ # This is to keep from having to explicitly mention it in the
+ # table above (i.e. lazy).
+ if name != corename:
+ libs += [corename]
+
+ e = env.Clone()
+ e.Append(
+ LIBS = Split(libs),
+ LIBPATH = ['.'],
+ LINKFLAGS = ['-Wl,--as-needed', '-Wl,-z,defs',
+ '-Wl,-soname,lib%s.so' % name],
+ )
+ if pc_libs:
+ e.ParseConfig(PKG_CONFIG + ' --cflags --libs %s' % pc_libs)
+ all_scons_libs += [ e.SharedLibrary(name, Split(lib['sources'])) ]
+
+
+# Build the random text files (pkg-config and linker script).
+
+def lib_list(libs):
+ return ' '.join(['-l' + l for l in libs])
-# glib and dbug environment
-env.ParseConfig(
- PKG_CONFIG + ' --cflags --libs dbus-1 glib-2.0 dbus-glib-1' +
- ' dbus-c++-1 libchrome')
-env.StaticLibrary('chromeos', SOURCES)
+subst_dict = {
+ '@BSLOT@' : BASE_VER,
+ '@PRIVATE_PC@' : all_pc_libs,
+ '@BASE_LIBS@' : lib_list(all_base_libs),
+ '@LIBS@' : lib_list(all_libs),
+}
+env = Environment(tools = ['textfile'], SUBST_DICT = subst_dict)
+
+env.Substfile(source = 'libchromeos.pc.in',
+ target = 'lib%s.pc' % libchromeos)
+env.Depends('lib%s.so' % libchromeos, all_scons_libs)
+env.Substfile('lib%s.so' % libchromeos,
+ [Value('GROUP ( AS_NEEDED ( @BASE_LIBS@ ) )')])
# Unit test
if ARGUMENTS.get('debug', 0):
- env.Append(
- CCFLAGS = ['-fprofile-arcs', '-ftest-coverage', '-fno-inline'],
- LIBS = ['gcov'],
- )
-
-env_test = env.Clone()
+ env_test.Append(
+ CCFLAGS = ['-fprofile-arcs', '-ftest-coverage', '-fno-inline'],
+ LIBS = ['gcov'],
+ )
env_test.Append(
- LIBS = ['gtest', 'rt'],
+ LIBS = [libchromeos, 'gtest', 'rt'],
LIBPATH = ['.', '../third_party/chrome'],
+ LINKFLAGS = ['-Wl,-rpath,\'$$ORIGIN\':.'],
)
+env_test.ParseConfig(PKG_CONFIG + ' --cflags --libs dbus-1 glib-2.0 ' +
+ 'dbus-glib-1 dbus-c++-1 openssl lib%s' % libchrome)
-# Use libchromeos instead of passing in LIBS in order to always
-# get the version we just built, not what was previously installed.
unittest_sources =['chromeos/glib/object_unittest.cc',
'chromeos/process_test.cc',
- 'chromeos/utility_test.cc',
- 'libchromeos.a']
+ 'chromeos/utility_test.cc']
unittest_main = ['testrunner.cc']
unittest_cmd = env_test.Program('unittests',
unittest_sources + unittest_main)
@@ -83,6 +159,7 @@ Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') +
# --------------------------------------------------
# Prepare and build the policy serving library.
+libpolicy = 'policy-%s' % BASE_VER
PROTO_PATH = '%susr/include/proto' % ROOT
PROTO_FILES = ['%s/chrome_device_policy.proto' % PROTO_PATH,
'%s/device_management_backend.proto' % PROTO_PATH]
@@ -97,8 +174,10 @@ POLICY_SOURCES=PROTO_SOURCES + \
env = common_env()
env.Append(
- LIBS = ['protobuf-lite'],
+ LIBS = [libchromeos, 'protobuf-lite', 'pthread', 'rt'],
LIBPATH = ['.', '../third_party/chrome'],
+ LINKFLAGS = ['-Wl,--as-needed', '-Wl,-z,defs',
+ '-Wl,-soname,lib%s.so' % libpolicy],
)
# Build the protobuf definitions.
@@ -109,21 +188,21 @@ env.Command(PROTO_SOURCES + PROTO_HEADERS,
'--cpp_out=chromeos/policy/bindings %s') % (
PROTO_PATH, ' '.join(PROTO_FILES)));
-env.StaticLibrary('policy', POLICY_SOURCES)
-env.ParseConfig(PKG_CONFIG + ' --cflags --libs glib-2.0 libchrome openssl')
-env.SharedLibrary('policy', POLICY_SOURCES)
+env.SharedLibrary(libpolicy, POLICY_SOURCES)
+env.ParseConfig(PKG_CONFIG + ' --cflags --libs glib-2.0 openssl ' +
+ 'lib%s' % libchrome)
# Prepare the test case as well
-env_test = env.Clone()
-
+env_test = common_env()
env_test.Append(
- LIBS = ['gtest', 'base', 'rt', 'pthread'],
+ LIBS = [libpolicy, 'gtest', 'rt', 'pthread'],
LIBPATH = ['.'],
+ LINKFLAGS = ['-Wl,-rpath,\'$$ORIGIN\':.'],
)
+env_test.ParseConfig(PKG_CONFIG + ' --cflags --libs lib%s' % libchrome)
# Use libpolicy instead of passing in LIBS in order to always
# get the version we just built, not what was previously installed.
-unittest_sources=['chromeos/policy/tests/libpolicy_unittest.cc',
- 'libpolicy.a']
+unittest_sources=['chromeos/policy/tests/libpolicy_unittest.cc']
env_test.ParseConfig(PKG_CONFIG + ' --cflags --libs glib-2.0 openssl')
env_test.Program('libpolicy_unittest', unittest_sources)
diff --git a/libchromeos.pc b/libchromeos.pc
deleted file mode 100644
index 212a779..0000000
--- a/libchromeos.pc
+++ /dev/null
@@ -1,5 +0,0 @@
-Name: libchromeos
-Description: chromeos base library
-Version: 0.0.0
-Requires: dbus-1 glib-2.0 dbus-glib-1 dbus-c++-1 libchrome openssl
-Libs: -lchromeos
diff --git a/libchromeos.pc.in b/libchromeos.pc.in
new file mode 100644
index 0000000..df08321
--- /dev/null
+++ b/libchromeos.pc.in
@@ -0,0 +1,7 @@
+bslot=@BSLOT@
+
+Name: libchromeos
+Description: chromeos base library
+Version: ${bslot}
+Requires.private: libchrome-${bslot} @PRIVATE_PC@
+Libs: -lchromeos-${bslot}