tools: kexttool: include directory support; pre-processor defines for internal kexts
This commit is contained in:
6
Makefile
6
Makefile
@@ -48,12 +48,14 @@ CWARNINGS := -Wall -Werror -pedantic -Wno-language-extension-token -Wno-unused-f
|
|||||||
OPTIMISATION_LEVEL := -O2
|
OPTIMISATION_LEVEL := -O2
|
||||||
|
|
||||||
CFLAGS := $(CFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" $(OPTIMISATION_LEVEL) -g -fPIC -std=gnu17 \
|
CFLAGS := $(CFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" $(OPTIMISATION_LEVEL) -g -fPIC -std=gnu17 \
|
||||||
-Iinclude -Iarch/$(SOCKS_ARCH)/include -Ilibc/include $(CWARNINGS)
|
-Iinclude -Iarch/$(SOCKS_ARCH)/include -Ilibc/include $(CWARNINGS) \
|
||||||
|
$(INTERNAL_KEXT_INCLUDES) $(INTERNAL_KEXT_DEFINES)
|
||||||
|
|
||||||
KERNEL_DEFINES := -DSOCKS_INTERNAL=1
|
KERNEL_DEFINES := -DSOCKS_INTERNAL=1
|
||||||
|
|
||||||
CXXFLAGS := $(CXXFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" $(OPTIMISATION_LEVEL) -g -fPIC -std=gnu++17 \
|
CXXFLAGS := $(CXXFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" $(OPTIMISATION_LEVEL) -g -fPIC -std=gnu++17 \
|
||||||
-Iinclude -Iarch/$(SOCKS_ARCH)/include -Ilibc/include -Wno-language-extension-token $(CWARNINGS)
|
-Iinclude -Iarch/$(SOCKS_ARCH)/include -Ilibc/include -Wno-language-extension-token $(CWARNINGS) \
|
||||||
|
$(INTERNAL_KEXT_INCLUDES) $(INTERNAL_KEXT_DEFINES)
|
||||||
|
|
||||||
ASMFLAGS := $(ASMFLAGS) -DBUILD_ID=\"$(BUILD_ID)\"
|
ASMFLAGS := $(ASMFLAGS) -DBUILD_ID=\"$(BUILD_ID)\"
|
||||||
LDFLAGS := $(LDFLAGS) -g -lgcc $(OPTIMISATION_LEVEL)
|
LDFLAGS := $(LDFLAGS) -g -lgcc $(OPTIMISATION_LEVEL)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import yaml
|
import yaml
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from kexttool.kext import KextSource
|
from kexttool.kext import KextSource
|
||||||
|
|
||||||
|
|
||||||
@@ -84,6 +85,12 @@ def write_external_kext_variables(fp, kexts):
|
|||||||
fp.write('\n')
|
fp.write('\n')
|
||||||
|
|
||||||
|
|
||||||
|
def c_define_from_kext_id(ident):
|
||||||
|
out = ident.upper()
|
||||||
|
out = re.sub('[^0-9a-zA-Z]+', '_', out)
|
||||||
|
return 'KEXT_{}'.format(out)
|
||||||
|
|
||||||
|
|
||||||
def create_kext_makefile():
|
def create_kext_makefile():
|
||||||
all_kexts = KextSource.scan(os.path.join(os.getcwd(), 'kexts'))
|
all_kexts = KextSource.scan(os.path.join(os.getcwd(), 'kexts'))
|
||||||
selection_info = {}
|
selection_info = {}
|
||||||
@@ -102,6 +109,7 @@ def create_kext_makefile():
|
|||||||
return
|
return
|
||||||
|
|
||||||
internal_source_files = []
|
internal_source_files = []
|
||||||
|
internal_kexts = []
|
||||||
external_kexts = []
|
external_kexts = []
|
||||||
|
|
||||||
print('the following kernel extensions will be built:')
|
print('the following kernel extensions will be built:')
|
||||||
@@ -119,6 +127,7 @@ def create_kext_makefile():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if build_info['build'] == 'internal':
|
if build_info['build'] == 'internal':
|
||||||
|
internal_kexts.append(kext_info)
|
||||||
internal_source_files += kext_info.sources_filepath()
|
internal_source_files += kext_info.sources_filepath()
|
||||||
elif build_info['build'] == 'external':
|
elif build_info['build'] == 'external':
|
||||||
external_kexts.append(kext_info)
|
external_kexts.append(kext_info)
|
||||||
@@ -141,11 +150,30 @@ def create_kext_makefile():
|
|||||||
makefile_fp.write(' \\')
|
makefile_fp.write(' \\')
|
||||||
makefile_fp.write('\n')
|
makefile_fp.write('\n')
|
||||||
|
|
||||||
|
if len(internal_kexts) > 0:
|
||||||
|
makefile_fp.write('INTERNAL_KEXT_DEFINES := \\\n')
|
||||||
|
|
||||||
|
for i, kext_info in enumerate(internal_kexts):
|
||||||
|
makefile_fp.write('\t-D{}=1'.format(c_define_from_kext_id(kext_info.id())))
|
||||||
|
|
||||||
|
if i != len(internal_kexts) - 1:
|
||||||
|
makefile_fp.write(' \\')
|
||||||
|
makefile_fp.write('\n')
|
||||||
|
|
||||||
|
if len(internal_kexts) > 0:
|
||||||
|
makefile_fp.write('INTERNAL_KEXT_INCLUDES := \\\n')
|
||||||
|
|
||||||
|
for i, kext_info in enumerate(internal_kexts):
|
||||||
|
makefile_fp.write('\t-I{}'.format(os.path.join('$(ROOT_DIR)', kext_info.src_dirpath(), 'include')))
|
||||||
|
|
||||||
|
if i != len(selection_info.items()) - 1:
|
||||||
|
makefile_fp.write(' \\')
|
||||||
|
makefile_fp.write('\n')
|
||||||
|
|
||||||
write_external_kext_variables(makefile_fp, external_kexts)
|
write_external_kext_variables(makefile_fp, external_kexts)
|
||||||
|
|
||||||
for kext in external_kexts:
|
for kext in external_kexts:
|
||||||
makefile_fp.write('\nkexts/{}: $({})\n'.format(kext.id(), external_kext_obj_variable_name(kext)))
|
makefile_fp.write('\nkexts/{}: $({})\n'.format(kext.id(), external_kext_obj_variable_name(kext)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def select_kexts():
|
def select_kexts():
|
||||||
|
|||||||
Reference in New Issue
Block a user