Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
26998893
Commit
26998893
authored
Sep 20, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python/build/cmake.py: use CMAKE_TOOLCHAIN_FILE
Let cmake know that we're cross-crompiling.
parent
e4f93336
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
12 deletions
+41
-12
build.py
android/build.py
+1
-0
cmake.py
python/build/cmake.py
+39
-12
build.py
win32/build.py
+1
-0
No files found.
android/build.py
View file @
26998893
...
...
@@ -83,6 +83,7 @@ class AndroidNdkToolchain:
install_prefix
=
os
.
path
.
join
(
arch_path
,
'root'
)
self
.
arch
=
arch
self
.
actual_arch
=
arch
self
.
install_prefix
=
install_prefix
llvm_path
=
os
.
path
.
join
(
ndk_path
,
'toolchains'
,
'llvm'
,
'prebuilt'
,
build_arch
)
...
...
python/build/cmake.py
View file @
26998893
import
os
import
subprocess
from
build.project
import
Project
def
__
cmake_compiler_args
(
language
,
compiler
):
def
__
write_cmake_compiler
(
f
,
language
,
compiler
):
s
=
compiler
.
split
(
' '
,
1
)
result
=
[]
if
len
(
s
)
==
2
:
result
.
append
(
f
'-DCMAKE_{language}_COMPILER_LAUNCHER={s[0]}'
)
print
(
f
'set(CMAKE_{language}_COMPILER_LAUNCHER {s[0]})'
,
file
=
f
)
compiler
=
s
[
1
]
result
.
append
(
f
'-DCMAKE_{language}_COMPILER={compiler}'
)
return
result
print
(
f
'set(CMAKE_{language}_COMPILER {compiler})'
,
file
=
f
)
def
__write_cmake_toolchain_file
(
f
,
toolchain
):
if
'-darwin'
in
toolchain
.
actual_arch
:
cmake_system_name
=
'Darwin'
elif
toolchain
.
is_windows
:
cmake_system_name
=
'Windows'
else
:
cmake_system_name
=
'Linux'
f
.
write
(
f
"""
set(CMAKE_SYSTEM_NAME {cmake_system_name})
set(CMAKE_SYSTEM_PROCESSOR {toolchain.actual_arch.split('-', 1)[0]})
set(CMAKE_C_COMPILER_TARGET {toolchain.actual_arch})
set(CMAKE_CXX_COMPILER_TARGET {toolchain.actual_arch})
set(CMAKE_C_FLAGS "{toolchain.cflags} {toolchain.cppflags}")
set(CMAKE_CXX_FLAGS "{toolchain.cxxflags} {toolchain.cppflags}")
"""
)
__write_cmake_compiler
(
f
,
'C'
,
toolchain
.
cc
)
__write_cmake_compiler
(
f
,
'CXX'
,
toolchain
.
cxx
)
def
configure
(
toolchain
,
src
,
build
,
args
=
()):
cross_args
=
[]
if
toolchain
.
is_windows
:
cross_args
.
append
(
'-DCMAKE_SYSTEM_NAME=Windows'
)
cross_args
.
append
(
'-DCMAKE_RC_COMPILER='
+
toolchain
.
windres
)
# Several targets need a sysroot to prevent pkg-config from
# looking for libraries on the build host (TODO: fix this
# properly); but we must not do that on Android because the NDK
# has a sysroot already
if
'-android'
not
in
toolchain
.
actual_arch
and
'-darwin'
not
in
toolchain
.
actual_arch
:
cross_args
.
append
(
'-DCMAKE_SYSROOT='
+
toolchain
.
install_prefix
)
os
.
makedirs
(
build
,
exist_ok
=
True
)
cmake_toolchain_file
=
os
.
path
.
join
(
build
,
'cmake_toolchain_file'
)
with
open
(
cmake_toolchain_file
,
'w'
)
as
f
:
__write_cmake_toolchain_file
(
f
,
toolchain
)
configure
=
[
'cmake'
,
src
,
'-DCMAKE_TOOLCHAIN_FILE='
+
cmake_toolchain_file
,
'-DCMAKE_INSTALL_PREFIX='
+
toolchain
.
install_prefix
,
'-DCMAKE_BUILD_TYPE=release'
,
]
+
\
__cmake_compiler_args
(
'C'
,
toolchain
.
cc
)
+
\
__cmake_compiler_args
(
'CXX'
,
toolchain
.
cxx
)
+
\
[
'-DCMAKE_C_FLAGS='
+
toolchain
.
cflags
+
' '
+
toolchain
.
cppflags
,
'-DCMAKE_CXX_FLAGS='
+
toolchain
.
cxxflags
+
' '
+
toolchain
.
cppflags
,
'-GNinja'
,
]
+
cross_args
+
args
...
...
win32/build.py
View file @
26998893
...
...
@@ -38,6 +38,7 @@ class CrossGccToolchain:
def
__init__
(
self
,
toolchain_path
,
arch
,
tarball_path
,
src_path
,
build_path
,
install_prefix
):
self
.
arch
=
arch
self
.
actual_arch
=
arch
self
.
tarball_path
=
tarball_path
self
.
src_path
=
src_path
self
.
build_path
=
build_path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment