Commit | Line | Data |
---|---|---|
d25bc64b JY |
1 | # |
2 | # (C) COPYRIGHT 2010-2015 ARM Limited. All rights reserved. | |
3 | # | |
4 | # This program is free software and is provided to you under the terms of the | |
5 | # GNU General Public License version 2 as published by the Free Software | |
6 | # Foundation, and any use by you of this program is subject to the terms | |
7 | # of such GNU licence. | |
8 | # | |
9 | # A copy of the licence is included with the program, and can also be obtained | |
10 | # from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
11 | # Boston, MA 02110-1301, USA. | |
12 | # | |
13 | # | |
14 | ||
15 | ||
16 | ||
17 | import os | |
18 | import re | |
19 | import sys | |
20 | Import('env') | |
21 | ||
22 | if Glob('tests/sconscript'): | |
23 | SConscript( 'tests/sconscript' ) | |
24 | ||
25 | mock_test = 0 | |
26 | ||
27 | if env['v'] != '1': | |
28 | env['MAKECOMSTR'] = '[MAKE] ${SOURCE.dir}' | |
29 | ||
30 | # Fake platform is a transient solution for GPL drivers running in kernel that does not provide configuration via platform data. | |
31 | # For such kernels fake_platform_device should be set to 1. For kernels providing platform data fake_platform_device should be set to 0. | |
32 | if env['platform_config']=='devicetree': | |
33 | fake_platform_device = 0 | |
34 | else: | |
35 | fake_platform_device = 1 | |
36 | ||
37 | # Source files required for kbase. | |
38 | kbase_src = [Glob('#kernel/drivers/gpu/arm/midgard/*.c'), | |
39 | Glob('#kernel/drivers/gpu/arm/midgard/*.c'), | |
40 | Glob('#kernel/drivers/gpu/arm/midgard/backend/*/*.c'), | |
41 | Glob('#kernel/drivers/gpu/arm/midgard/backend/*/*.h'), | |
42 | Glob('#kernel/drivers/gpu/arm/midgard/platform/%s/*.c' % (env['platform_config'])), | |
43 | Glob('#kernel/drivers/gpu/arm/midgard/*.h'), | |
44 | Glob('#kernel/drivers/gpu/arm/midgard/*.h'), | |
45 | Glob('#kernel/drivers/gpu/arm/midgard/Makefile', | |
46 | Glob('#kernel/drivers/gpu/arm/midgard/K*')) | |
47 | ] | |
48 | ||
49 | kbase_src += [Glob('#kernel/drivers/gpu/arm/midgard/internal/*/*.c'), | |
50 | Glob('#kernel/drivers/gpu/arm/midgard/internal/*/*/*.c')] | |
51 | ||
52 | if Glob('#kernel/drivers/gpu/arm/midgard/tests/internal/src/mock') and env['unit'] == '1': | |
53 | kbase_src += [Glob('#kernel/drivers/gpu/arm/midgard/tests/internal/src/mock/*.c')] | |
54 | mock_test = 1 | |
55 | ||
56 | # we need platform config for GPL version using fake platform | |
57 | if fake_platform_device==1: | |
58 | # Check if we are compiling for PBX | |
59 | linux_config_file = os.path.normpath(os.environ['KDIR']) + '/.config' | |
60 | search_term = '^[\ ]*CONFIG_MACH_REALVIEW_PBX[\ ]*=[\ ]*y' | |
61 | REALVIEW_PBX = 0 | |
62 | for line in open(linux_config_file, 'r'): | |
63 | if re.search(search_term, line): | |
64 | REALVIEW_PBX = 1 | |
65 | break | |
66 | if REALVIEW_PBX == 1 and (env['platform_config'] == 'vexpress' or env['platform_config'] == 'vexpress_6xvirtex7_10mhz'): | |
67 | sys.stderr.write("WARNING: Building for a PBX kernel but with platform_config=vexpress*\n") | |
68 | # if the file platform config file is in the tpip directory then use that, otherwise use the default config directory | |
69 | if Glob('#kernel/drivers/gpu/arm/midgard/config/tpip/*%s.c' % (env['platform_config'])): | |
70 | kbase_src += Glob('#kernel/drivers/gpu/arm/midgard/config/tpip/*%s.c' % (env['platform_config'])) | |
71 | else: | |
72 | kbase_src += Glob('#kernel/drivers/gpu/arm/midgard/config/*%s.c' % (env['platform_config'])) | |
73 | ||
74 | # Note: cleaning via the Linux kernel build system does not yet work | |
75 | if env.GetOption('clean') : | |
76 | env.Execute(Action("make clean", '[clean] kbase')) | |
77 | cmd = env.Command(['$STATIC_LIB_PATH/mali_kbase.ko', '$STATIC_LIB_PATH/mali_platform_fake.ko'], kbase_src, []) | |
78 | else: | |
79 | if env['os'] == 'android': | |
80 | env['android'] = 1 | |
81 | else: | |
82 | env['android'] = 0 | |
83 | ||
84 | if env['unit'] == '1': | |
85 | env['kernel_test'] = 1 | |
86 | else: | |
87 | env['kernel_test'] = 0 | |
88 | ||
89 | #Extract environment options, note the trailing spaces are important | |
90 | env_options = \ | |
91 | "PLATFORM=${platform} " +\ | |
92 | "MALI_ERROR_INJECT_ON=${error_inject} " +\ | |
93 | "MALI_ANDROID=${android} " +\ | |
94 | "MALI_KERNEL_TEST_API=${kernel_test} " +\ | |
95 | "MALI_UNIT_TEST=${unit} " +\ | |
96 | "MALI_RELEASE_NAME=\"${mali_release_name}\" "+\ | |
97 | "MALI_MOCK_TEST=%s " % mock_test +\ | |
98 | "MALI_CUSTOMER_RELEASE=${release} " +\ | |
99 | "MALI_INSTRUMENTATION_LEVEL=${instr} " +\ | |
100 | "MALI_COVERAGE=${coverage} " +\ | |
101 | "MALI_BUS_LOG=${buslog} " | |
102 | ||
103 | make_action_start = "cd ${SOURCE.dir} && make -j%d " % GetOption('num_jobs') | |
104 | make_action_end = "%s && cp mali_kbase.ko $STATIC_LIB_PATH/mali_kbase.ko" % env.kernel_get_config_defines(fake_platform_device) | |
105 | make_action = make_action_start + env_options + make_action_end | |
106 | ||
107 | makeAction=Action(make_action, '$MAKECOMSTR') | |
108 | cmd = env.Command('$STATIC_LIB_PATH/mali_kbase.ko', kbase_src, [makeAction]) | |
109 | ||
110 | # Add a dependency on kds.ko. | |
111 | # Only necessary when KDS is not built into the kernel. | |
112 | # | |
113 | if env['os'] != 'android': | |
114 | linux_config_file = os.path.normpath(os.environ['KDIR']) + '/.config' | |
115 | search_term = '^[\ ]*CONFIG_KDS[\ ]*=[\ ]*y' | |
116 | kds_in_kernel = 0 | |
117 | for line in open(linux_config_file, 'r'): | |
118 | if re.search(search_term, line): | |
119 | # KDS in kernel. | |
120 | kds_in_kernel = 1 | |
121 | if not kds_in_kernel: | |
122 | env.Depends('$STATIC_LIB_PATH/mali_kbase.ko', '$STATIC_LIB_PATH/kds.ko') | |
123 | ||
124 | # need Module.symvers from ump.ko build | |
125 | if int(env['ump']) == 1: | |
126 | env.Depends('$STATIC_LIB_PATH/mali_kbase.ko', '$STATIC_LIB_PATH/ump.ko') | |
127 | ||
128 | if Glob('internal/sconsfrag'): | |
129 | execfile('internal/sconsfrag') | |
130 | get_internal(env) | |
131 | ||
132 | env.ProgTarget('kbase', cmd) | |
133 | ||
134 | env.AppendUnique(BASE=['cutils_linked_list']) |