Skip to content

Commit 1f5f043

Browse files
committed
Initial build setup
1 parent 6a9b887 commit 1f5f043

File tree

8 files changed

+604
-0
lines changed

8 files changed

+604
-0
lines changed

.gn

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Use Python 3 for exec_script() calls.
2+
# See "gn help dotfile" for details.
3+
script_executable = "python3"
4+
5+
# The location of the build configuration file.
6+
buildconfig = "//build/config/BUILDCONFIG.gn"
7+
8+
# The secondary source root is a parallel directory tree where
9+
# GN build files are placed when they can not be placed directly
10+
# in the source tree, e.g. for third party source trees.
11+
secondary_source = "//build/secondary/"

BUILD.gn

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
group("tizen") {
6+
deps = [ "//flutter/shell/platform/tizen:flutter_tizen" ]
7+
}
8+
9+
group("unittests") {
10+
testonly = true
11+
12+
deps = [ "//flutter/shell/platform/tizen:flutter_tizen_unittests" ]
13+
}

DEPS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
deps = {
6+
'src/third_party/rapidjson': 'https://fuchsia.googlesource.com/third_party/rapidjson@ef3564c5c8824989393b87df25355baf35ff544b',
7+
'src/third_party/libcxx': 'https://llvm.googlesource.com/llvm-project/libcxx@54c3dc7343f40254bdb069699202e6d65eda66a2',
8+
'src/third_party/libcxxabi': 'https://llvm.googlesource.com/llvm-project/libcxxabi@65a68da0f1b102574db316d326a53735b03a4574',
9+
'src/third_party/googletest': 'https://github.com/google/googletest@054a986a8513149e8374fc669a5fe40117ca6b41',
10+
'src/third_party/dart': 'https://dart.googlesource.com/sdk.git@63c2197b976931c6472d9dc9574f98ff2ae9408c',
11+
'src/third_party/gn': {
12+
'packages': [
13+
{
14+
'package': 'gn/gn/${{platform}}',
15+
'version': 'git_revision:b79031308cc878488202beb99883ec1f2efd9a6d',
16+
},
17+
],
18+
'dep_type': 'cipd',
19+
},
20+
}

build/config/BUILD.gn

Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
# Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
config("compiler") {
6+
assert(sysroot_path != "")
7+
8+
cflags = [
9+
"-fPIC",
10+
"-pipe",
11+
"-pthread",
12+
"-fcolor-diagnostics",
13+
"-fvisibility=hidden",
14+
]
15+
cflags_c = [ "-fno-strict-aliasing" ]
16+
cflags_cc = [
17+
"-fvisibility-inlines-hidden",
18+
"-fno-exceptions",
19+
]
20+
include_dirs = [ "${sysroot_path}/usr/include" ]
21+
defines = []
22+
ldflags = [
23+
"-fPIC",
24+
"-pthread",
25+
"-Wl,--fatal-warnings",
26+
"-Wl,-z,noexecstack",
27+
"-Wl,-z,now",
28+
"-Wl,-z,relro",
29+
"-Wl,-z,defs",
30+
]
31+
lib_dirs = [
32+
"${sysroot_path}/usr/lib",
33+
"${sysroot_path}/usr/lib64",
34+
]
35+
libs = [ "dl" ]
36+
37+
# Stack protection.
38+
cflags += [
39+
"-fstack-protector",
40+
"--param=ssp-buffer-size=4",
41+
]
42+
43+
# Cross compilation.
44+
if (target_cpu == "x64") {
45+
cflags += [
46+
"-m64",
47+
"-march=x86-64",
48+
]
49+
ldflags += [ "-m64" ]
50+
} else if (target_cpu == "x86") {
51+
cflags += [
52+
"-m32",
53+
"-mstack-alignment=16",
54+
"-mstackrealign",
55+
]
56+
ldflags += [ "-m32" ]
57+
} else if (target_cpu == "arm") {
58+
cflags += [
59+
"-march=armv7-a",
60+
"-mfloat-abi=softfp",
61+
"-mtune=generic-armv7-a",
62+
"-mthumb",
63+
"-mfpu=neon",
64+
]
65+
} else if (target_cpu == "arm64") {
66+
cflags += [ "--target=aarch64-linux-gnu" ]
67+
ldflags += [ "--target=aarch64-linux-gnu" ]
68+
}
69+
70+
# Compiler warnings.
71+
cflags += [
72+
"-Wall",
73+
"-Wextra",
74+
"-Wendif-labels",
75+
"-Werror",
76+
"-Wno-missing-field-initializers",
77+
"-Wno-unused-parameter",
78+
"-Wno-implicit-int-float-conversion",
79+
"-Wno-c99-designator",
80+
"-Wno-deprecated-copy",
81+
"-Wno-range-loop-construct",
82+
]
83+
if (clang_version >= 11) {
84+
cflags += [ "-Wno-psabi" ]
85+
}
86+
if (clang_version >= 14) {
87+
cflags += [
88+
"-Wno-unused-but-set-parameter",
89+
"-Wno-unused-but-set-variable",
90+
"-Wno-non-c-typedef-for-linkage",
91+
]
92+
}
93+
if (clang_version >= 15) {
94+
cflags += [ "-Wno-unqualified-std-cast-call" ]
95+
}
96+
97+
# Extra warnings.
98+
cflags += [
99+
"-Wstring-conversion",
100+
"-Wnewline-eof",
101+
]
102+
103+
# Symbols.
104+
cflags += [ "-g${symbol_level}" ]
105+
}
106+
107+
config("cxx_version_default") {
108+
cflags_cc = [ "-std=c++17" ]
109+
}
110+
111+
config("cxx_version_11") {
112+
cflags_cc = [ "-std=c++11" ]
113+
}
114+
115+
config("no_system_cxx") {
116+
cflags_cc = [ "-nostdinc++" ]
117+
ldflags = [ "-nostdlib++" ]
118+
include_dirs = [
119+
"//third_party/libcxx/include",
120+
"//third_party/libcxxabi/include",
121+
]
122+
}
123+
124+
config("system_cxx") {
125+
assert(sysroot_path != "")
126+
127+
if (target_cpu == "arm64") {
128+
lib_path = "${sysroot_path}/usr/lib64"
129+
} else {
130+
lib_path = "${sysroot_path}/usr/lib"
131+
}
132+
133+
if (target_cpu == "arm") {
134+
gcc_target_triple = "armv7l-tizen-linux-gnueabi"
135+
} else if (target_cpu == "arm64") {
136+
gcc_target_triple = "aarch64-tizen-linux-gnu"
137+
} else if (target_cpu == "x86") {
138+
gcc_target_triple = "i586-tizen-linux-gnu"
139+
} else {
140+
assert(false, "Unknown target_cpu: " + target_cpu)
141+
}
142+
143+
include_dirs = [
144+
"${lib_path}/gcc/${gcc_target_triple}/9.2.0/include",
145+
"${lib_path}/gcc/${gcc_target_triple}/9.2.0/include/c++",
146+
"${lib_path}/gcc/${gcc_target_triple}/9.2.0/include/c++/${gcc_target_triple}",
147+
]
148+
libs = [ "stdc++" ]
149+
}
150+
151+
config("no_optimize") {
152+
defines = [ "_DEBUG" ]
153+
cflags = [ "-O0" ]
154+
}
155+
156+
config("optimize") {
157+
defines = [ "NDEBUG" ]
158+
cflags = [
159+
"-O2",
160+
"-fno-ident",
161+
]
162+
ldflags = [
163+
"-Wl,-O2",
164+
"-Wl,--as-needed",
165+
]
166+
167+
# Put data and code in their own sections, so that unused symbols
168+
# can be removed at link time.
169+
cflags += [
170+
"-fdata-sections",
171+
"-ffunction-sections",
172+
]
173+
ldflags += [ "-Wl,--gc-sections" ]
174+
}
175+
176+
config("ldconfig") {
177+
ldflags = [ "-Wl,-rpath=\$ORIGIN" ]
178+
}
179+
180+
toolchain("clang") {
181+
assert(toolchain_path != "")
182+
assert(sysroot_path != "")
183+
assert(target_triple != "")
184+
185+
cc = "${toolchain_path}/bin/clang"
186+
cxx = "${toolchain_path}/bin/clang++"
187+
ld = "${toolchain_path}/bin/clang++"
188+
ar = "${target_triple}-ar"
189+
nm = "${target_triple}-nm"
190+
readelf = "${target_triple}-readelf"
191+
strip = "${target_triple}-strip"
192+
193+
target_triple_flags = "--target=${target_triple}"
194+
sysroot_flags = "--sysroot=${sysroot_path}"
195+
196+
tool("cc") {
197+
depfile = "{{output}}.d"
198+
command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
199+
depsformat = "gcc"
200+
description = "CC {{output}}"
201+
outputs =
202+
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
203+
}
204+
205+
tool("cxx") {
206+
depfile = "{{output}}.d"
207+
command = "$cxx -MD -MF $depfile $target_triple_flags $sysroot_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
208+
depsformat = "gcc"
209+
description = "CXX {{output}}"
210+
outputs =
211+
[ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
212+
}
213+
214+
tool("alink") {
215+
rspfile = "{{output}}.rsp"
216+
command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile"
217+
description = "AR {{output}}"
218+
rspfile_content = "{{inputs}}"
219+
outputs =
220+
[ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ]
221+
default_output_extension = ".a"
222+
output_prefix = "lib"
223+
}
224+
225+
tool("solink") {
226+
soname = "{{target_output_name}}{{output_extension}}"
227+
sofile = "{{root_out_dir}}/${soname}"
228+
unstripped_sofile = "{{root_out_dir}}/so.unstripped/${soname}"
229+
rspfile = sofile + ".rsp"
230+
tocfile = sofile + ".TOC"
231+
temporary_tocname = sofile + ".tmp"
232+
233+
link_command = "$ld $target_triple_flags $sysroot_flags -shared {{ldflags}} -o $unstripped_sofile -Wl,--build-id=sha1 -Wl,-soname=${soname} @${rspfile}"
234+
toc_command = "{ $readelf -d $unstripped_sofile | grep SONAME; $nm -gD -f posix $unstripped_sofile | cut -f1-2 -d' '; } > $temporary_tocname"
235+
replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi"
236+
strip_command = "$strip -o $sofile $unstripped_sofile"
237+
238+
command =
239+
"$link_command && $toc_command && $replace_command && $strip_command"
240+
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
241+
242+
description = "SOLINK $sofile"
243+
default_output_extension = ".so"
244+
output_prefix = "lib"
245+
246+
# Since the above commands only updates the .TOC file when it changes, ask
247+
# Ninja to check if the timestamp actually changed to know if downstream
248+
# dependencies should be recompiled.
249+
restat = true
250+
251+
outputs = [
252+
sofile,
253+
unstripped_sofile,
254+
tocfile,
255+
]
256+
257+
link_output = sofile
258+
depend_output = tocfile
259+
}
260+
261+
tool("link") {
262+
exename = "{{target_output_name}}{{output_extension}}"
263+
outfile = "{{root_out_dir}}/$exename"
264+
rspfile = "$outfile.rsp"
265+
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
266+
command = "$ld $target_triple_flags $sysroot_flags {{ldflags}} -o $unstripped_outfile -Wl,--build-id=sha1 -Wl,--start-group @${rspfile} {{solibs}} -Wl,--end-group {{libs}} && $strip -o $outfile $unstripped_outfile"
267+
description = "LINK $outfile"
268+
rspfile_content = "{{inputs}}"
269+
outputs = [
270+
unstripped_outfile,
271+
outfile,
272+
]
273+
}
274+
275+
tool("stamp") {
276+
command = "touch {{output}}"
277+
description = "STAMP {{output}}"
278+
}
279+
280+
tool("copy") {
281+
command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
282+
description = "COPY {{source}} {{output}}"
283+
}
284+
}

0 commit comments

Comments
 (0)