Added a script to copy all header files into a sysroot
This commit is contained in:
@@ -18,6 +18,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/platform.cmake)
|
|||||||
platform_config(${PHOTON_TARGET})
|
platform_config(${PHOTON_TARGET})
|
||||||
|
|
||||||
message(STATUS "Target: ${machine}-${platform}")
|
message(STATUS "Target: ${machine}-${platform}")
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/target.txt "${machine}-${platform}")
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/config.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${platform}/config.cmake)
|
||||||
|
|
||||||
|
|||||||
56
scripts/generate-sysroot.py
Executable file
56
scripts/generate-sysroot.py
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import errno
|
||||||
|
from shutil import copy2
|
||||||
|
|
||||||
|
|
||||||
|
def get_platform(out_dir):
|
||||||
|
platform_file = open(out_dir + '/target.txt')
|
||||||
|
content = platform_file.read()
|
||||||
|
spl = content.find('-')
|
||||||
|
return (content[:spl], content[spl + 1:])
|
||||||
|
|
||||||
|
|
||||||
|
def copy_headers(src_dir, dest_dir):
|
||||||
|
for filename in os.listdir(src_dir):
|
||||||
|
if filename.endswith(".h") and not filename.startswith("__"):
|
||||||
|
copy2(os.path.join(src_dir, filename), dest_dir)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
def mkdir_p(path):
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except OSError as exc:
|
||||||
|
if exc.errno == errno.EEXIST and os.path.isdir(path):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
source_dir = sys.argv[1]
|
||||||
|
bin_dir = sys.argv[2]
|
||||||
|
sysroot_dir = sys.argv[3]
|
||||||
|
(machine, platform) = get_platform(bin_dir)
|
||||||
|
|
||||||
|
base_headers_path = '{}/photon/libc/include'.format(source_dir)
|
||||||
|
platform_headers_path = '{}/photon/libc/sys/{}'.format(source_dir, platform)
|
||||||
|
platform_sys_headers_path = '{}/photon/libc/sys/{}/sys'.format(source_dir, platform)
|
||||||
|
platform_sys_arch_headers_path = '{}/photon/libc/sys/{}/machine/{}'.format(source_dir, platform, machine)
|
||||||
|
|
||||||
|
machine_arch_headers_path = '{}/photon/libc/machine/{}'.format(source_dir, machine)
|
||||||
|
machine_generic_headers_path = '{}/photon/libc/include/machine'.format(source_dir)
|
||||||
|
|
||||||
|
mkdir_p(sysroot_dir + '/usr/include/sys')
|
||||||
|
mkdir_p(sysroot_dir + '/usr/include/machine')
|
||||||
|
|
||||||
|
copy_headers(base_headers_path, sysroot_dir + '/usr/include')
|
||||||
|
copy_headers(platform_headers_path, sysroot_dir + '/usr/include')
|
||||||
|
copy_headers(platform_sys_headers_path, sysroot_dir + '/usr/include/sys')
|
||||||
|
copy_headers(platform_sys_arch_headers_path, sysroot_dir + '/usr/include/sys')
|
||||||
|
|
||||||
|
#copy_headers(machine_arch_headers_path, sysroot_dir + '/usr/include/machine')
|
||||||
|
copy_headers(machine_generic_headers_path, sysroot_dir + '/usr/include/machine')
|
||||||
Reference in New Issue
Block a user