mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-24 16:57:21 +00:00
Enable building of Cgpt C++ Library for 32-bit.
The existing library had a bunch of dependencies which are too many to build for the 32-bit platform. So this checkin prunes the dependency list by building only things that are absolutely required for the functionality used in 32-bit Post-Installer. Made the use of libuuid restricted only to cgpt and unit tests so that libcgpt-cc.a doesn't depend on it. BUG=chromium-os:25374 TEST=Built 32-bit and 64-bit. Tested 32-bit post-install. Change-Id: Idd0826fdf507a95728fee8adac9520e26f05d469 Reviewed-on: https://gerrit.chromium.org/gerrit/16433 Reviewed-by: Don Garrett <dgarrett@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org> Commit-Ready: Jay Srinivasan <jaysri@chromium.org> Tested-by: Jay Srinivasan <jaysri@chromium.org>
This commit is contained in:
12
Makefile
12
Makefile
@@ -105,9 +105,17 @@ all:
|
||||
make -C $$i; \
|
||||
done
|
||||
|
||||
libcgpt_cc: all
|
||||
libcgpt_cc:
|
||||
mkdir -p ${BUILD}/cgpt ${BUILD}/firmware/lib/cgptlib ${BUILD}/firmware/stub
|
||||
$(MAKE) -C cgpt libcgpt_cc
|
||||
$(MAKE) -C tests CgptManagerTests
|
||||
|
||||
cgptmanager_tests: libcgpt_cc
|
||||
mkdir -p ${BUILD}/tests
|
||||
$(MAKE) -C tests cgptmanager_tests
|
||||
|
||||
libdump_kernel_config:
|
||||
mkdir -p ${BUILD}/utility
|
||||
$(MAKE) -C utility $(DUMPKERNELCONFIGLIB)
|
||||
|
||||
clean:
|
||||
/bin/rm -rf ${BUILD}
|
||||
|
||||
@@ -15,6 +15,8 @@ using std::string;
|
||||
// We don't use these variables for the libcgpt version.
|
||||
const char* progname = "";
|
||||
const char* command = "";
|
||||
void (*uuid_generator)(uint8_t* buffer) = NULL;
|
||||
|
||||
|
||||
// This file implements the C++ wrapper methods over the C cgpt methods.
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#define VBOOT_REFERENCE_CGPT_CGPTMANAGER_H_
|
||||
|
||||
#include <string>
|
||||
#include <base/basictypes.h>
|
||||
#include "gpt.h"
|
||||
|
||||
// This file defines a simple C++ wrapper class interface for the cgpt methods.
|
||||
@@ -166,7 +165,8 @@ class CgptManager {
|
||||
std::string device_name_;
|
||||
bool is_initialized_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CgptManager);
|
||||
CgptManager(const CgptManager &);
|
||||
void operator=(const CgptManager &);
|
||||
};
|
||||
|
||||
#endif // VBOOT_REFERENCE_CGPT_CGPTMANAGER_H_
|
||||
|
||||
@@ -33,18 +33,28 @@ ALL_SRCS = \
|
||||
cgpt_common.c
|
||||
|
||||
LIB_CGPT_CC_SRCS = \
|
||||
CgptManager.cc
|
||||
CgptManager.cc \
|
||||
cgpt_create.c \
|
||||
cgpt_add.c \
|
||||
cgpt_boot.c \
|
||||
cgpt_show.c \
|
||||
cgpt_repair.c \
|
||||
cgpt_prioritize.c \
|
||||
cgpt_common.c \
|
||||
../firmware/lib/cgptlib/crc32.c \
|
||||
../firmware/lib/cgptlib/cgptlib_internal.c \
|
||||
../firmware/stub/utility_stub.c
|
||||
|
||||
main: $(PROGNAME)
|
||||
|
||||
include ../common.mk
|
||||
|
||||
LIB_CGPT_CC_OBJS = $(LIB_CGPT_CC_SRCS:%.cc=${BUILD_ROOT}/%.o)
|
||||
LIB_CGPT_CC_OBJS = $(LIB_CGPT_CC_SRCS:%.c=${BUILD_ROOT}/%.o) $(LIB_CGPT_CC_SRCS:%.cc=${BUILD_ROOT}/%.o)
|
||||
LIB_CGPT_CC_DEPS = $(LIB_CGPT_CC_OBJS:%.o=%.o.d)
|
||||
|
||||
libcgpt_cc: main $(LIB_CGPT_CC)
|
||||
libcgpt_cc: $(LIB_CGPT_CC)
|
||||
|
||||
$(LIB_CGPT_CC): $(ALL_OBJS) $(LIB_CGPT_CC_OBJS)
|
||||
$(LIB_CGPT_CC): $(LIB_CGPT_CC_OBJS)
|
||||
rm -f $@
|
||||
ar qc $@ $^
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
const char* progname;
|
||||
const char* command;
|
||||
void (*uuid_generator)(uint8_t* buffer);
|
||||
|
||||
struct {
|
||||
const char *name;
|
||||
@@ -51,6 +52,8 @@ int main(int argc, char *argv[]) {
|
||||
int match_count = 0;
|
||||
int match_index = 0;
|
||||
|
||||
uuid_generator = uuid_generate;
|
||||
|
||||
progname = strrchr(argv[0], '/');
|
||||
if (progname)
|
||||
progname++;
|
||||
|
||||
@@ -136,6 +136,13 @@ extern const char* progname;
|
||||
extern const char* command;
|
||||
void Error(const char *format, ...);
|
||||
|
||||
// The code paths that require uuid_generate are not used currently in
|
||||
// libcgpt-cc.a so using this method would create an unnecessary dependency
|
||||
// on libuuid which then requires us to build it for 32-bit for the static
|
||||
// post-installer. So, we just expose this function pointer which should be
|
||||
// set to uuid_generate in case of the cgpt binary and can be null or some
|
||||
// no-op method in case of ilbcgpt-cc.a.
|
||||
extern void (*uuid_generator)(uint8_t* buffer);
|
||||
|
||||
// Command functions.
|
||||
int cmd_show(int argc, char *argv[]);
|
||||
|
||||
@@ -233,7 +233,11 @@ int cgpt_add(CgptAddParams *params) {
|
||||
goto bad;
|
||||
}
|
||||
if (!params->set_unique)
|
||||
uuid_generate((uint8_t *)&entry->unique);
|
||||
if (!uuid_generator) {
|
||||
Error("Unable to generate new GUID. uuid_generator not set.\n");
|
||||
goto bad;
|
||||
}
|
||||
(*uuid_generator)((uint8_t *)&entry->unique);
|
||||
}
|
||||
|
||||
if (params->set_begin)
|
||||
|
||||
@@ -42,7 +42,11 @@ int cgpt_create(CgptCreateParams *params) {
|
||||
h->alternate_lba = drive.gpt.drive_sectors - 1;
|
||||
h->first_usable_lba = 1 + 1 + GPT_ENTRIES_SECTORS;
|
||||
h->last_usable_lba = drive.gpt.drive_sectors - 1 - GPT_ENTRIES_SECTORS - 1;
|
||||
uuid_generate((uint8_t *)&h->disk_uuid);
|
||||
if (!uuid_generator) {
|
||||
Error("Unable to generate new GUID. uuid_generator not set.\n");
|
||||
goto bad;
|
||||
}
|
||||
(*uuid_generator)((uint8_t *)&h->disk_uuid);
|
||||
h->entries_lba = 2;
|
||||
h->number_of_entries = 128;
|
||||
h->size_of_entry = sizeof(GptEntry);
|
||||
@@ -55,4 +59,9 @@ int cgpt_create(CgptCreateParams *params) {
|
||||
|
||||
// Write it all out
|
||||
return DriveClose(&drive, 1);
|
||||
|
||||
bad:
|
||||
|
||||
DriveClose(&drive, 0);
|
||||
return CGPT_FAILED;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ extern "C" {
|
||||
#include <base/logging.h>
|
||||
#include <gflags/gflags.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
using std::string;
|
||||
|
||||
@@ -36,7 +37,12 @@ DEFINE_int32(v, 0, 0);
|
||||
// This class unit tests the CgptManager class.
|
||||
class CgptManagerUnitTest : public ::testing::Test {
|
||||
public:
|
||||
CgptManagerUnitTest() { }
|
||||
CgptManagerUnitTest() {
|
||||
// Even though the post-installer doesn't use any methods that require
|
||||
// uuid_generate, for the unit test we use those methods, so we need to
|
||||
// set the uuid_generator.
|
||||
uuid_generator = uuid_generate;
|
||||
}
|
||||
|
||||
void SetUp() {
|
||||
const string device_name = "/tmp/DummyFileForCgptManagerTests.bin";
|
||||
|
||||
@@ -59,6 +59,8 @@ all: $(TEST_BINS) ${EXTRA_TARGET}
|
||||
|
||||
rbtest: $(BUILD_ROOT)/rollback_index_test
|
||||
|
||||
cgptmanager_tests: $(BUILD_ROOT)/CgptManagerTests
|
||||
|
||||
${TEST_LIB}: ${TEST_LIB_OBJS}
|
||||
rm -f $@
|
||||
ar qc $@ $^
|
||||
@@ -67,9 +69,9 @@ ${TEST_LIB}: ${TEST_LIB_OBJS}
|
||||
${BUILD_ROOT}/CgptManagerTests.o: CgptManagerTests.cc
|
||||
$(CXX) -DWITH_UTIL_MAIN $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
CgptManagerTests: ${BUILD_ROOT}/CgptManagerTests.o ${LIBS}
|
||||
${BUILD_ROOT}/CgptManagerTests: ${BUILD_ROOT}/CgptManagerTests.o
|
||||
$(CXX) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS) -lgtest -lgflags $^ \
|
||||
${BUILD}/cgpt/libcgpt-cc.a ${FWLIB} $(HOSTLIB) -lbase -lpthread -lrt -o ${BUILD_ROOT}/$@
|
||||
${BUILD}/cgpt/libcgpt-cc.a -lbase -lpthread -lrt -o $@
|
||||
|
||||
${BUILD_ROOT}/vboot_audio_for_test.o : $(FWDIR)/lib/vboot_audio.c
|
||||
$(CC) $(CFLAGS) -DCUSTOM_MUSIC $(INCLUDES) \
|
||||
|
||||
Reference in New Issue
Block a user