blob: d531f4b316c092492de5073df7c9e129e34bb8f5 [file] [log] [blame]
Jorge Lucangeli Obesa21c8fc2015-07-15 16:22:34 -07001# Copyright (C) 2015 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15LOCAL_PATH := $(call my-dir)
16
Jorge Lucangeli Obesb845b152015-12-08 20:52:41 -080017
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -080018# Common variables.
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -080019# =========================================================
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -080020libminijailSrcFiles := \
21 bpf.c \
22 libminijail.c \
23 signal_handler.c \
24 syscall_filter.c \
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -040025 syscall_wrapper.c \
Jorge Lucangeli Obes0b208772017-04-19 14:15:46 -040026 system.c \
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -080027 util.c
28
Luis Hector Chavez114a9302017-09-05 20:36:58 -070029targetUnittestSrcFiles := \
30 testrunner.cc
31
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -040032hostUnittestSrcFiles := \
33 linux-x86/libconstants.gen.c \
Luis Hector Chavez114a9302017-09-05 20:36:58 -070034 linux-x86/libsyscalls.gen.c \
35 testrunner.cc
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -040036
Jorge Lucangeli Obesf783b522016-03-14 14:34:10 -070037minijailCommonCFlags := -DHAVE_SECUREBITS_H -Wall -Werror
Jorge Lucangeli Obes6fd82bd2015-12-15 09:28:52 -080038minijailCommonLibraries := libcap
Jorge Lucangeli Obesa21c8fc2015-07-15 16:22:34 -070039
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -080040
Jorge Lucangeli Obesc37681d2015-10-28 10:41:39 -070041# Static library for generated code.
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -080042# =========================================================
Jorge Lucangeli Obesc37681d2015-10-28 10:41:39 -070043include $(CLEAR_VARS)
44LOCAL_MODULE := libminijail_generated
Jiyong Park351d9862017-04-18 23:51:27 +090045include $(LOCAL_PATH)/gen.mk
46include $(BUILD_STATIC_LIBRARY)
Jorge Lucangeli Obesa21c8fc2015-07-15 16:22:34 -070047
Jiyong Park351d9862017-04-18 23:51:27 +090048include $(CLEAR_VARS)
49LOCAL_MODULE:= libminijail_generated_vendor
50include $(LOCAL_PATH)/gen.mk
51LOCAL_VENDOR_MODULE := true
Jorge Lucangeli Obesc37681d2015-10-28 10:41:39 -070052include $(BUILD_STATIC_LIBRARY)
53
Jorge Lucangeli Obesb845b152015-12-08 20:52:41 -080054
Jorge Lucangeli Obesc37681d2015-10-28 10:41:39 -070055# libminijail shared library for target.
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -080056# =========================================================
Jorge Lucangeli Obesa21c8fc2015-07-15 16:22:34 -070057include $(CLEAR_VARS)
58LOCAL_MODULE := libminijail
59
Jorge Lucangeli Obesa21c8fc2015-07-15 16:22:34 -070060LOCAL_CFLAGS := $(minijailCommonCFlags)
61LOCAL_CLANG := true
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -080062LOCAL_SRC_FILES := $(libminijailSrcFiles)
Jorge Lucangeli Obes8b330bf2015-08-04 10:42:05 -070063
Jorge Lucangeli Obesc37681d2015-10-28 10:41:39 -070064LOCAL_STATIC_LIBRARIES := libminijail_generated
Jorge Lucangeli Obes6fd82bd2015-12-15 09:28:52 -080065LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
Jorge Lucangeli Obes8b330bf2015-08-04 10:42:05 -070066LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
Jorge Lucangeli Obesa21c8fc2015-07-15 16:22:34 -070067include $(BUILD_SHARED_LIBRARY)
Jorge Lucangeli Obesc37681d2015-10-28 10:41:39 -070068
Jiyong Park351d9862017-04-18 23:51:27 +090069include $(CLEAR_VARS)
70LOCAL_MODULE := libminijail_vendor
71
72LOCAL_CFLAGS := $(minijailCommonCFlags)
73LOCAL_CLANG := true
74LOCAL_SRC_FILES := $(libminijailSrcFiles)
75LOCAL_VENDOR_MODULE := true
76
77LOCAL_STATIC_LIBRARIES := libminijail_generated_vendor
78LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
79LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
80include $(BUILD_SHARED_LIBRARY)
Jorge Lucangeli Obesb845b152015-12-08 20:52:41 -080081
Jorge Lucangeli Obes2413f372016-04-06 18:43:10 -070082# Example ASan-ified libminijail shared library for target.
83# Commented out since it's only needed for local debugging.
84# =========================================================
85# include $(CLEAR_VARS)
86# LOCAL_MODULE := libminijail_asan
87# LOCAL_MODULE_TAGS := optional
88#
89# LOCAL_CFLAGS := $(minijailCommonCFlags)
90# LOCAL_CLANG := true
91# LOCAL_SANITIZE := address
92# LOCAL_MODULE_RELATIVE_PATH := asan
93# LOCAL_SRC_FILES := $(libminijailSrcFiles)
94#
95# LOCAL_STATIC_LIBRARIES := libminijail_generated
96# LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
97# LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
98# include $(BUILD_SHARED_LIBRARY)
99
100
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -0800101# libminijail static library for target.
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -0800102# =========================================================
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -0800103include $(CLEAR_VARS)
104LOCAL_MODULE := libminijail
105
106LOCAL_CFLAGS := $(minijailCommonCFlags)
107LOCAL_CLANG := true
108LOCAL_SRC_FILES := $(libminijailSrcFiles)
109
Jorge Lucangeli Obesd2045ac2016-01-08 13:21:48 -0800110LOCAL_WHOLE_STATIC_LIBRARIES := libminijail_generated $(minijailCommonLibraries)
Jorge Lucangeli Obes43e29b32015-12-08 21:07:14 -0800111LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
112include $(BUILD_STATIC_LIBRARY)
113
114
Jorge Lucangeli Obesa67bd6a2016-08-19 15:33:48 -0400115# libminijail native unit tests using gtest. Run with:
116# adb shell /data/nativetest/libminijail_unittest_gtest/libminijail_unittest_gtest
117# =========================================================
118include $(CLEAR_VARS)
119LOCAL_MODULE := libminijail_unittest_gtest
Dan Shi3b526012017-03-28 10:40:35 -0700120LOCAL_COMPATIBILITY_SUITE := device-tests
Jorge Lucangeli Obesa67bd6a2016-08-19 15:33:48 -0400121
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500122LOCAL_CPP_EXTENSION := .cc
Jorge Lucangeli Obesa67bd6a2016-08-19 15:33:48 -0400123LOCAL_CFLAGS := $(minijailCommonCFlags) -Wno-writable-strings
124LOCAL_CLANG := true
125LOCAL_SRC_FILES := \
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400126 $(libminijailSrcFiles) \
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500127 libminijail_unittest.cc \
Luis Hector Chavez114a9302017-09-05 20:36:58 -0700128 $(targetUnittestSrcFiles)
Jorge Lucangeli Obesa67bd6a2016-08-19 15:33:48 -0400129
130LOCAL_STATIC_LIBRARIES := libminijail_generated
131LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
132include $(BUILD_NATIVE_TEST)
133
134
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500135# # libminijail native unit tests for the host. Run with:
136# # out/host/linux-x86/nativetest(64)/libminijail_unittest/libminijail_unittest_gtest
137# # TODO(b/31395668): Re-enable once the seccomp(2) syscall becomes available.
138# # =========================================================
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400139# include $(CLEAR_VARS)
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500140# LOCAL_MODULE := libminijail_unittest_gtest
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400141# LOCAL_MODULE_HOST_OS := linux
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400142
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500143# LOCAL_CPP_EXTENSION := .cc
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400144# LOCAL_CFLAGS := $(minijailCommonCFlags) -DPRELOADPATH=\"/invalid\"
145# LOCAL_CLANG := true
146# LOCAL_SRC_FILES := \
147# $(libminijailSrcFiles) \
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500148# libminijail_unittest.cc \
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400149# $(hostUnittestSrcFiles)
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400150
Jorge Lucangeli Obes13650612016-09-02 11:27:29 -0400151# LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
152# include $(BUILD_HOST_NATIVE_TEST)
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400153
154
Jorge Lucangeli Obes106d97f2016-08-19 12:34:02 -0400155# Syscall filtering native unit tests using gtest. Run with:
156# adb shell /data/nativetest/syscall_filter_unittest_gtest/syscall_filter_unittest_gtest
157# =========================================================
158include $(CLEAR_VARS)
159LOCAL_MODULE := syscall_filter_unittest_gtest
Dan Shi3b526012017-03-28 10:40:35 -0700160LOCAL_COMPATIBILITY_SUITE := device-tests
Jorge Lucangeli Obes106d97f2016-08-19 12:34:02 -0400161
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500162LOCAL_CPP_EXTENSION := .cc
Jorge Lucangeli Obes106d97f2016-08-19 12:34:02 -0400163LOCAL_CFLAGS := $(minijailCommonCFlags)
164LOCAL_CLANG := true
165LOCAL_SRC_FILES := \
166 bpf.c \
167 syscall_filter.c \
168 util.c \
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500169 syscall_filter_unittest.cc \
Luis Hector Chavez114a9302017-09-05 20:36:58 -0700170 $(targetUnittestSrcFiles)
Jorge Lucangeli Obes106d97f2016-08-19 12:34:02 -0400171
172LOCAL_STATIC_LIBRARIES := libminijail_generated
173LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
174include $(BUILD_NATIVE_TEST)
175
176
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400177# Syscall filtering native unit tests for the host. Run with:
Jorge Lucangeli Obes45932a52017-03-15 17:02:58 -0400178# out/host/linux-x86/nativetest(64)/syscall_filter_unittest_gtest/syscall_filter_unittest_gtest
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400179# =========================================================
180include $(CLEAR_VARS)
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500181LOCAL_MODULE := syscall_filter_unittest_gtest
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400182LOCAL_MODULE_HOST_OS := linux
183
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500184LOCAL_CPP_EXTENSION := .cc
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400185LOCAL_CFLAGS := $(minijailCommonCFlags)
186LOCAL_CLANG := true
187LOCAL_SRC_FILES := \
188 bpf.c \
189 syscall_filter.c \
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400190 util.c \
Jorge Lucangeli Obes9bd316b2017-01-26 17:21:16 -0500191 syscall_filter_unittest.cc \
Jorge Lucangeli Obes2aa880c2016-08-01 16:16:35 -0400192 $(hostUnittestSrcFiles)
193
194LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
195include $(BUILD_HOST_NATIVE_TEST)
196
197
Mike Frysinger0b5cffa2017-08-15 18:06:18 -0400198# System functionality unit tests using gtest. Run with:
199# adb shell /data/nativetest/system_unittest_gtest/system_unittest_gtest
200# =========================================================
201include $(CLEAR_VARS)
202LOCAL_MODULE := system_unittest_gtest
203LOCAL_COMPATIBILITY_SUITE := device-tests
204
205LOCAL_CPP_EXTENSION := .cc
206LOCAL_CFLAGS := $(minijailCommonCFlags)
207LOCAL_CLANG := true
208LOCAL_SRC_FILES := \
209 system.c \
Luis Hector Chavez114a9302017-09-05 20:36:58 -0700210 util.c \
Mike Frysinger0b5cffa2017-08-15 18:06:18 -0400211 system_unittest.cc \
Luis Hector Chavez114a9302017-09-05 20:36:58 -0700212 $(targetUnittestSrcFiles)
Mike Frysinger0b5cffa2017-08-15 18:06:18 -0400213
214LOCAL_STATIC_LIBRARIES := libminijail_generated
215LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
216include $(BUILD_NATIVE_TEST)
217
218
219# System functionality native unit tests for the host. Run with:
220# out/host/linux-x86/nativetest(64)/system_unittest_gtest/system_unittest_gtest
221# =========================================================
222include $(CLEAR_VARS)
223LOCAL_MODULE := system_unittest_gtest
224LOCAL_MODULE_HOST_OS := linux
225
226LOCAL_CPP_EXTENSION := .cc
227LOCAL_CFLAGS := $(minijailCommonCFlags)
228LOCAL_CLANG := true
229LOCAL_SRC_FILES := \
230 system.c \
Luis Hector Chavez114a9302017-09-05 20:36:58 -0700231 util.c \
Mike Frysinger0b5cffa2017-08-15 18:06:18 -0400232 system_unittest.cc \
233 $(hostUnittestSrcFiles)
234
235LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries)
236include $(BUILD_HOST_NATIVE_TEST)
237
238
Jorge Lucangeli Obesf9fcdbe2016-02-19 15:04:09 -0800239# libminijail_test executable for brillo_Minijail test.
Jorge Lucangeli Obesac9e3422016-02-03 15:00:42 -0800240# =========================================================
241include $(CLEAR_VARS)
242LOCAL_MODULE := libminijail_test
Dan Shi3b526012017-03-28 10:40:35 -0700243LOCAL_COMPATIBILITY_SUITE := device-tests
Jorge Lucangeli Obesac9e3422016-02-03 15:00:42 -0800244
245LOCAL_CFLAGS := $(minijailCommonCFlags)
246LOCAL_CLANG := true
Jorge Lucangeli Obes64efa552017-03-14 14:57:50 -0400247LOCAL_GTEST := false
Jorge Lucangeli Obesac9e3422016-02-03 15:00:42 -0800248LOCAL_SRC_FILES := \
249 test/libminijail_test.cpp
250
251LOCAL_SHARED_LIBRARIES := libbase libminijail
Jorge Lucangeli Obes64efa552017-03-14 14:57:50 -0400252include $(BUILD_NATIVE_TEST)
Jorge Lucangeli Obesac9e3422016-02-03 15:00:42 -0800253
254
Jorge Lucangeli Obes6f967c52015-12-04 14:44:53 -0800255# libminijail usage example.
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -0800256# =========================================================
Jorge Lucangeli Obes6f967c52015-12-04 14:44:53 -0800257include $(CLEAR_VARS)
258LOCAL_MODULE := drop_privs
259LOCAL_MODULE_TAGS := optional
260LOCAL_CFLAGS := $(minijailCommonCFlags)
261LOCAL_CLANG := true
Jorge Lucangeli Obes9e35c092016-04-11 13:30:08 -0700262# Don't build with ASan, but leave commented out for easy local debugging.
263# LOCAL_SANITIZE := address
Jorge Lucangeli Obes6f967c52015-12-04 14:44:53 -0800264LOCAL_SRC_FILES := \
265 examples/drop_privs.cpp
266
267LOCAL_SHARED_LIBRARIES := libbase libminijail
268include $(BUILD_EXECUTABLE)
Jorge Lucangeli Obesd99a40d2016-01-26 13:50:44 -0800269
270
271# minijail0 executable.
272# This is not currently used on Brillo/Android,
273# but it's convenient to be able to build it.
274# =========================================================
275include $(CLEAR_VARS)
276LOCAL_MODULE := minijail0
277LOCAL_MODULE_TAGS := optional
278LOCAL_CFLAGS := \
279 $(minijailCommonCFlags) -Wno-missing-field-initializers \
280 -DPRELOADPATH=\"/invalidminijailpreload.so\"
281LOCAL_CLANG := true
282LOCAL_SRC_FILES := \
283 elfparse.c \
284 minijail0.c \
285
286LOCAL_STATIC_LIBRARIES := libminijail_generated
287LOCAL_SHARED_LIBRARIES := $(minijailCommonLibraries) libminijail
288include $(BUILD_EXECUTABLE)