Skip to content

Commit

Permalink
[makefile] Lib with Smart Card Connector application (#991)
Browse files Browse the repository at this point in the history
Create a separate static library containing the Connector's
application.cc logic, as opposed to compiling this file 3 times for each
target that needed it (executable_module, cpp_unittests,
js_to_cxx_tests).

This reduces duplication across different makefiles and should slightly
improve overall build times. This contributes to #869 as it introduced
one extra recompilation of the same source.
  • Loading branch information
emaxx-google authored Aug 30, 2023
1 parent 9226250 commit 12c780f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 17 deletions.
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ APPLICATION_TARGETS :=

LIBRARY_TARGETS := \
common/cpp/build \
smart_card_connector_app/build/cpp_lib \
third_party/ccid/webport/build \
third_party/libusb/webport/build \
third_party/pcsc-lite/naclport/build_configuration \
Expand All @@ -45,6 +46,7 @@ example_cpp_smart_card_client_app/build: third_party/pcsc-lite/naclport/common/b
example_cpp_smart_card_client_app/build: third_party/pcsc-lite/naclport/cpp_client/build
example_cpp_smart_card_client_app/build: third_party/pcsc-lite/naclport/cpp_demo/build
smart_card_connector_app/build: common/cpp/build
smart_card_connector_app/build: smart_card_connector_app/build/cpp_lib
smart_card_connector_app/build: third_party/ccid/webport/build
smart_card_connector_app/build: third_party/libusb/webport/build
smart_card_connector_app/build: third_party/pcsc-lite/naclport/common/build
Expand All @@ -63,7 +65,13 @@ TEST_TARGETS := \
third_party/libusb/webport/build/tests \

common/cpp/build/tests: common/cpp/build
smart_card_connector_app/build/executable_module/cpp_unittests: smart_card_connector_app/build
smart_card_connector_app/build/executable_module/cpp_unittests: common/cpp/build
smart_card_connector_app/build/executable_module/cpp_unittests: smart_card_connector_app/build/cpp_lib
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/ccid/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/libusb/webport/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/pcsc-lite/naclport/common/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/pcsc-lite/naclport/server/build
smart_card_connector_app/build/executable_module/cpp_unittests: third_party/pcsc-lite/naclport/server_clients_management/build
third_party/libusb/webport/build/tests: common/cpp/build
third_party/libusb/webport/build/tests: third_party/libusb/webport/build

Expand Down Expand Up @@ -119,7 +127,12 @@ example_cpp_smart_card_client_app/build/js_to_cxx_tests: common/integration_test
example_cpp_smart_card_client_app/build/js_to_cxx_tests: example_cpp_smart_card_client_app/build
smart_card_connector_app/build/js_to_cxx_tests: common/cpp/build
smart_card_connector_app/build/js_to_cxx_tests: common/integration_testing/build
smart_card_connector_app/build/js_to_cxx_tests: smart_card_connector_app/build
smart_card_connector_app/build/js_to_cxx_tests: smart_card_connector_app/build/cpp_lib
smart_card_connector_app/build/js_to_cxx_tests: third_party/ccid/webport/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/libusb/webport/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/pcsc-lite/naclport/common/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/pcsc-lite/naclport/server/build
smart_card_connector_app/build/js_to_cxx_tests: third_party/pcsc-lite/naclport/server_clients_management/build

endif

Expand Down
4 changes: 4 additions & 0 deletions smart_card_connector_app/build/cpp_lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/out-artifacts-asan_testing/
/out-artifacts-coverage/
/out-artifacts-emscripten/
/pnacl/
42 changes: 42 additions & 0 deletions smart_card_connector_app/build/cpp_lib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2023 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Builds the static library with the Smart Card Connector's core C/C++
# functionality.


TARGET := smart_card_connector_application

include ../../../common/make/common.mk
include $(ROOT_PATH)/common/make/executable_building.mk


SOURCES := \
$(ROOT_PATH)/smart_card_connector_app/src/application.cc \

CXXFLAGS := \
-I$(ROOT_PATH) \
-I$(ROOT_PATH)/common/cpp/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/naclport/server/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/naclport/server_clients_management/src \
-Wall \
-Werror \
-Wextra \
-Wno-zero-length-array \
-pedantic \
-std=$(CXX_DIALECT) \

# Rules for compiling source files and linking them into a static library.
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CXXFLAGS))))
$(eval $(call LIB_RULE,$(TARGET),$(SOURCES)))
5 changes: 1 addition & 4 deletions smart_card_connector_app/build/executable_module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ include $(THIRD_PARTY_DIR_PATH)/pcsc-lite/naclport/server_clients_management/inc
SOURCES_DIR := ../../src

SOURCES := \
$(SOURCES_DIR)/application.cc \

LIBS := \
smart_card_connector_application \
$(PCSC_LITE_SERVER_CLIENTS_MANAGEMENT_LIB) \
$(PCSC_LITE_SERVER_LIB) \
$(PCSC_LITE_COMMON_LIB) \
Expand All @@ -45,9 +45,6 @@ DEPS :=

CXXFLAGS := \
-I$(ROOT_PATH) \
-I$(ROOT_PATH)/common/cpp/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/naclport/server/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/naclport/server_clients_management/src \
-Wall \
-Werror \
-Wextra \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@

include ../../../../common/cpp_unit_test_runner/include.mk

# TODO: application.cc is also compiled by ../Makefile; consider avoiding the
# duplication.
SOURCES := \
../../../src/application.cc \
../../../src/application_unittest.cc \
../../../src/testing_smart_card_simulation.cc \

# Explanation:
# -Wno-zero-length-array: Suppress warnings in the third-party reader.h file.
CXXFLAGS := \
-I$(ROOT_PATH) \
-I$(ROOT_PATH)/common/cpp/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/naclport/server/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/naclport/server_clients_management/src \
-I$(ROOT_PATH)/third_party/pcsc-lite/src/src/PCSC \
-pedantic \
-Wall \
Expand All @@ -45,6 +39,7 @@ CXXFLAGS := \
# The libraries are listed in the topological order: a library should only use
# symbols from subsequent ones.
LIBS := \
smart_card_connector_application \
google_smart_card_pcsc_lite_server_clients_management \
google_smart_card_pcsc_lite_server \
google_smart_card_pcsc_lite_common \
Expand Down
9 changes: 4 additions & 5 deletions smart_card_connector_app/build/js_to_cxx_tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ include $(ROOT_PATH)/third_party/pcsc-lite/naclport/server_clients_management/in

SOURCE_DIR := $(ROOT_PATH)/smart_card_connector_app/src/

# TODO(emaxx): application.cc and testing_smart_card_simulation.cc are also
# compiled for other targets (both for ../executable_module/ and the latter for
# ../executable_module/cpp_unittests/). Get rid of duplicate compilation by
# putting them into static libraries.
# TODO(emaxx): testing_smart_card_simulation.cc is also compiled for other
# targets (for ../executable_module/cpp_unittests/). Get rid of duplicate
# compilation by putting them into static libraries.
CXX_SOURCES := \
$(SOURCE_DIR)/application.cc \
$(SOURCE_DIR)/application_integration_test_helper.cc \
$(SOURCE_DIR)/testing_smart_card_simulation.cc \

Expand All @@ -52,6 +50,7 @@ CXXFLAGS := \
-std=$(CXX_DIALECT) \

LIBS := \
smart_card_connector_application \
$(PCSC_LITE_SERVER_CLIENTS_MANAGEMENT_LIB) \
$(PCSC_LITE_SERVER_LIB) \
$(PCSC_LITE_COMMON_LIB) \
Expand Down

0 comments on commit 12c780f

Please sign in to comment.