NaCl libpcsc

Check-in [727411c09e]
Login
Overview
SHA1:727411c09ec37deff9b88e8ca954f74b715d09ee
Date: 2016-04-13 21:58:41
User: rkeene
Comment:First incomplete conversion from the old PCSC build to the new one
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-04-13
22:13
[60c7795ca7] Better targets (user: rkeene, tags: trunk)
21:58
[727411c09e] First incomplete conversion from the old PCSC build to the new one (user: rkeene, tags: trunk)
20:16
[a10d20a3d7] initial empty check-in (user: rkeene, tags: trunk)
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added Makefile version [1ca3a38e08].

            1  +# Setup cross-compiler toolchain
            2  +## Set path to include the tools
            3  +PATH := ${PATH}:${NACL_SDK_ROOT}/toolchain/linux_pnacl/bin
            4  +export PATH
            5  +
            6  +## Set variables needed by projects
            7  +HOST_CC      := $(shell which "$${CC:-cc}")
            8  +BUILD_CC     := ${HOST_CC}
            9  +CC_FOR_BUILD := ${HOST_CC}
           10  +AR           := pnacl-ar
           11  +AS           := pnacl-as
           12  +LD           := pnacl-ld
           13  +CC           := pnacl-clang
           14  +CXX          := pnacl-clang++
           15  +RANLIB       := pnacl-ranlib
           16  +STRIP        := pnacl-strip
           17  +OBJCOPY      := pnacl-objcopy
           18  +export HOST_CC BUILD_CC CC_FOR_BUILD AR AS LD CC CXX RANLIB STRIP OBJCOPY
           19  +
           20  +## Set some CFLAGS that the compiler fails to internally set
           21  +CFLAGS       := -I${NACL_SDK_ROOT}/include
           22  +CXXFLAGS     := $(CFLAGS)
           23  +CPPFLAGS     := $(CFLAGS)
           24  +export CFLAGS CXXFLAGS CPPFLAGS
           25  +
           26  +all: libpcsc.a
           27  +
           28  +libpcsc.a:
           29  +
           30  +boost: build-boost
           31  +	rm -rf boost
           32  +	./build-boost
           33  +
           34  +.PHONY: all

Added bin/download version [6ec0ffbfde].

            1  +#! /usr/bin/env bash
            2  +
            3  +url="$1"
            4  +file="$2"
            5  +hash="$3"
            6  +
            7  +if [ -f "${file}" ]; then
            8  +	exit 0
            9  +fi
           10  +
           11  +mkdir -p "$(dirname "${file}")"
           12  +
           13  +hashMethod='sha256'
           14  +
           15  +rm -f "${file}.new"
           16  +wget --header "X-Cache-URL: ${url}" -O "${file}.new" "http://hashcache.rkeene.org/${hashMethod}/${hash}" || \
           17  +	wget -O "${file}.new" "${url}" || \
           18  +	exit 1
           19  +
           20  +chkHash="$(openssl "${hashMethod}" "${file}.new" | sed 's@.*= *@@')"
           21  +
           22  +if [ "${chkHash}" != "${hash}" ]; then
           23  +	echo "error: Checksum mismatch: Got: ${chkHash}; Expected: ${hash}" >&2
           24  +
           25  +	exit 1
           26  +fi
           27  +
           28  +mv "${file}.new" "${file}"
           29  +
           30  +exit 0

Added bin/extract version [6d090e378d].

            1  +#! /usr/bin/env bash
            2  +
            3  +file="$1"
            4  +directory="$2"
            5  +
            6  +if [ ! -f "${file}" ]; then
            7  +	echo "error: Unable to extract \"${file}\"" >&2
            8  +
            9  +	exit 1
           10  +fi
           11  +
           12  +rm -rf "${directory}"
           13  +
           14  +mkdir -p "${directory}" || exit 1
           15  +(
           16  +	cd "${directory}" || exit 1
           17  +
           18  +	case "${file}" in
           19  +		*.tar.bz2|*.bz2)
           20  +			bzip2 -dc | tar -xf - || exit 1
           21  +			;;
           22  +		*.tar.gz|*.tgz)
           23  +			gzip -dc | tar -xf - || exit 1
           24  +			;;
           25  +		*.tar.xz|*.txz)
           26  +			xz -dc | tar -xf - || exit 1
           27  +			;;
           28  +		*.zip)
           29  +			cat > x.zip || exit 1
           30  +			unzip -q x.zip || exit 1
           31  +			rm -f x.zip
           32  +			;;
           33  +		*)
           34  +			echo "error: Don't know what to do with \"${file}\"" >&2
           35  +
           36  +			exit 1
           37  +			;;
           38  +	esac
           39  +
           40  +	if [ -d "$(echo *)" ]; then
           41  +		mv */* . >/dev/null 2>/dev/null
           42  +	fi
           43  +) < "${file}" || exit 1
           44  +
           45  +exit 0

Added build-boost version [451acab69b].

            1  +#! /usr/bin/env bash
            2  +
            3  +# 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d
            4  +
            5  +ourScript="$(which "$0")"
            6  +if ! head -3 "${ourScript}" 2>/dev/null | grep 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d >/dev/null; then
            7  +	echo "error: Unable to find ourselves" >&2
            8  +
            9  +	exit 1
           10  +fi
           11  +
           12  +cd "$(dirname "${ourScript}")" || exit 1
           13  +
           14  +PATH="${PATH}:$(pwd)/bin"
           15  +export PATH
           16  +
           17  +if [ -z "${NACL_SDK_ROOT}" ]; then
           18  +	echo "error: Please set NACL_SDK_ROOT to the path of the current NaCl SDK target" >&2
           19  +
           20  +	exit 1
           21  +fi
           22  +
           23  +if [ ! -d "${NACL_SDK_ROOT}/toolchain" ]; then
           24  +	echo "error: Invalid NACL_SDK_ROOT, not found: ${NACL_SDK_ROOT}/toolchain" >&2
           25  +
           26  +	exit 1
           27  +fi
           28  +
           29  +# Build "boost"
           30  +function buildBoost() {
           31  +	local version url pkg sha256 configure_extra
           32  +	local archive workdir
           33  +
           34  +	pkg='boost'
           35  +	version='1.57.0'
           36  +	url="http://downloads.sourceforge.net/project/boost/boost/${version}/boost_`echo ${version} | sed 's_\._\__g'`.tar.bz2"
           37  +	sha256='910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967'
           38  +
           39  +	archive="archive/${pkg}-${version}.tar.bz2"
           40  +	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
           41  +
           42  +	download "${url}" "${archive}" "${sha256}" || return 1
           43  +	extract "${archive}" "${workdir}" || return 1
           44  +
           45  +	(
           46  +		cd "${workdir}" || exit 1
           47  +
           48  +		./bootstrap.sh --prefix="${instdir}" --with-python=false --show-libraries
           49  +
           50  +		./bootstrap.sh --prefix="${instdir}" --with-python=false --without-libraries='atomic,chrono,container,context,coroutine,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,log,math,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,wave' || exit 1
           51  +
           52  +		echo "using gcc : pnacl : ${CXX} ;" >> project-config.jam
           53  +
           54  +		./b2 --debug-configuration toolset=gcc-pnacl target-os=linux link=static runtime-link=static || exit 1
           55  +
           56  +		./bjam install | grep -v '^common.copy '
           57  +
           58  +		exit 0
           59  +	) || return 1
           60  +
           61  +	rm -rf "${workdir}"
           62  +
           63  +	return 0
           64  +}
           65  +
           66  +rm -rf boost.new
           67  +instdir="$(pwd)/boost.new/boost"
           68  +mkdir -p "${instdir}"
           69  +
           70  +buildBoost || exit 1
           71  +
           72  +rm -rf 'boost'
           73  +mv "$(pwd)/boost.new/boost" "$(pwd)"
           74  +rm -rf boost.new
           75  +
           76  +exit 0

Added build/assemble-source-from-google.sh version [0f3dced8de].

            1  +#! /usr/bin/env bash
            2  +
            3  +# 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d
            4  +
            5  +ourScript="$(which "$0")"
            6  +if ! head -3 "${ourScript}" 2>/dev/null | grep 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d >/dev/null; then
            7  +	echo "error: Unable to find ourselves" >&2
            8  +
            9  +	exit 1
           10  +fi
           11  +
           12  +cd "$(dirname "${ourScript}")" || exit 1
           13  +cd .. || exit 1
           14  +
           15  +PATH="${PATH}:$(pwd)/bin"
           16  +export PATH
           17  +
           18  +# Build the libpcsc we need
           19  +function assemblePCSC() {
           20  +	local version url pkg sha256
           21  +	local archive workdir
           22  +
           23  +	pkg='google-chrome-smart-card-apps'
           24  +	version='20160317'
           25  +	sha256='a144a81be9fe72eb7698a7dc0c1aba6425220551cca432ba7e58984422a7cf46'
           26  +
           27  +	archive="archive/${pkg}-${version}-nobinaries.zip"
           28  +	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
           29  +
           30  +	extract "${archive}" "${workdir}" || return 1
           31  +
           32  +	(
           33  +		cd "${workdir}" || exit 1
           34  +
           35  +		# Copy out PC/SC headers for later use
           36  +		mkdir -p "${instdir}/include/PCSC" || exit 1
           37  +		cp third_party/pcsc-lite/src-*/src/PCSC/*.h "${instdir}/include/PCSC" || exit 1
           38  +
           39  +		# Copy out JavaScript files for later use
           40  +		mkdir "${instdir}/js" || exit 1
           41  +#		cp common-utils/*.js "${instdir}/js" || exit 1
           42  +#		cp third_party/pcsc-lite/client-side/*.js "${instdir}/js" || exit 1
           43  +
           44  +		# Assemble all the files into a single tree
           45  +		for file in logging.h scard_structs_serialization.h dom_requests_manager.h thread_safe_string_pool.h \
           46  +		    pp_var_utils.cc pp_var_utils.h scard_structs_serialization.cc dom_requests_manager.cc logging.cc; do
           47  +			find . -type f -name "${file}" -exec cp '{}' "${instdir}" ';'
           48  +		done
           49  +	) || return 1
           50  +
           51  +	rm -rf "${workdir}"
           52  +
           53  +	return 0
           54  +}
           55  +
           56  +instdir="$(pwd)/pcsc/src"
           57  +rm -rf "${instdir}"
           58  +mkdir -p "${instdir}"
           59  +
           60  +assemblePCSC || exit 1
           61  +
           62  +exit 0

Added pcsc/Makefile version [db5548a6ca].

            1  +CFLAGS   += -Wall -std=gnu++11 -g3 -ggdb3
            2  +CXXFLAGS += -Wall -std=gnu++11 -g3 -ggdb3
            3  +CPPFLAGS += -I../src/src/PCSC
            4  +
            5  +OBJS = pcsc_nacl.o pcsc_nacl_global.o scard_structs_serialization.o pp_var_utils.o logging.o dom_requests_manager.o pcsc_nacl_init.o
            6  +
            7  +all: libpcsc.a
            8  +
            9  +libpcsc.a: $(OBJS)
           10  +	rm -f libpcsc.a
           11  +	$(AR) rc libpcsc.a $(OBJS)
           12  +	-$(RANLIB) libpcsc.a
           13  +
           14  +pcsc_nacl_init.o: pcsc_nacl_init.cc pcsc_nacl_global.h dom_requests_manager.h pcsc_nacl.h
           15  +
           16  +pcsc_nacl.o: pcsc_nacl.cc pcsc_nacl.h logging.h pp_var_utils.h scard_structs_serialization.h
           17  +pcsc_nacl.h: dom_requests_manager.h thread_safe_string_pool.h
           18  +
           19  +pcsc_nacl_global.o: pcsc_nacl_global.cc pcsc_nacl_global.h logging.h
           20  +pcsc_nacl_global.h: pcsc_nacl.h
           21  +
           22  +pp_var_utils.o: pp_var_utils.cc pp_var_utils.h logging.h
           23  +pp_var_utils.h: logging.h
           24  +
           25  +scard_structs_serialization.o: scard_structs_serialization.cc scard_structs_serialization.h pp_var_utils.h
           26  +scard_structs_serialization.h: pp_var_utils.h
           27  +
           28  +dom_requests_manager.o: dom_requests_manager.cc dom_requests_manager.h logging.h pp_var_utils.h
           29  +
           30  +logging.o: logging.cc logging.h
           31  +
           32  +clean:
           33  +	rm -f $(OBJS)
           34  +	rm -f libpcsc.a
           35  +
           36  +distclean: clean
           37  +
           38  +.PHONY: all clean distclean

Added pcsc/pcsc-nacl.h version [5374437abd].

            1  +#ifndef PCSC_NACL_H
            2  +#define PCSC_NACL_H 1
            3  +#ifdef __cplusplus
            4  +#include <ppapi/cpp/core.h>
            5  +#include <ppapi/cpp/instance.h>
            6  +
            7  +void pcscNaClInit(pp::Instance *instance, pp::Core *core, const char *smartcardManagerAppId, const char *clientId);
            8  +bool pcscNaClHandleMessage(const pp::Var &message);
            9  +
           10  +#endif
           11  +#endif

Added pcsc/pcsc_nacl_init.cc version [683a161fcd].

            1  +#include <ppapi/cpp/core.h>
            2  +#include <ppapi/cpp/instance.h>
            3  +
            4  +#include <unistd.h>
            5  +
            6  +#include "pcsc_nacl_global.h"
            7  +#include "dom_requests_manager.h"
            8  +#include "pcsc_nacl.h"
            9  +
           10  +static DomRequestsManager *pcscNaClDRM = NULL;
           11  +
           12  +void pcscNaClInit(pp::Instance *instance, pp::Core *core, const char *smartcardManagerAppId, const char *clientId) {
           13  +	DomRequestsManager::PpDelegateImpl *drmDelegateImpl;
           14  +	PcscNacl *pcsc_nacl;
           15  +
           16  +	if (smartcardManagerAppId == NULL) {
           17  +		smartcardManagerAppId = "khpfeaanjngmcnplbdlpegiifgpfgdco";
           18  +	}
           19  +
           20  +	if (clientId == NULL) {
           21  +		clientId = "UNKNOWN";
           22  +	}
           23  +
           24  +	if (pcscNaClDRM == NULL) {
           25  +		drmDelegateImpl = new DomRequestsManager::PpDelegateImpl(instance, core);
           26  +	
           27  +		pcscNaClDRM = new DomRequestsManager("pcsc-nacl", drmDelegateImpl);
           28  +	}
           29  +
           30  +	pcsc_nacl = new PcscNacl(pcscNaClDRM, smartcardManagerAppId, clientId);
           31  +
           32  +	if (!pcsc_nacl->Initialize()) {
           33  +		return;
           34  +	}
           35  +
           36  +	SetPcscNaclGlobalInstance(pcsc_nacl);
           37  +
           38  +	return;
           39  +}
           40  +
           41  +bool pcscNaClHandleMessage(const pp::Var &message) {
           42  +	return(pcscNaClDRM->HandleMessage(message));
           43  +}