Skip to content

Commit

Permalink
refactor: Move some OS-specifics into tox_system.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Sep 8, 2023
1 parent 0cef46e commit cf46021
Show file tree
Hide file tree
Showing 169 changed files with 3,862 additions and 1,908 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_build
_install
2 changes: 1 addition & 1 deletion .github/scripts/flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_flag -O3 -march=native
# Warn on non-ISO C.
add_c_flag -pedantic
add_c_flag -std=c99
add_cxx_flag -std=c++11
add_cxx_flag -std=c++17

add_flag -g3
add_flag -ftrapv
54 changes: 49 additions & 5 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,73 @@ package(features = ["layering_check"])

project()

genrule(
name = "toxcore_headers",
srcs = ["//c-toxcore/toxcore:public"],
outs = [
"tox/toxcore/os_log.h",
"tox/toxcore/os_memory.h",
"tox/toxcore/os_network.h",
"tox/toxcore/os_random.h",
"tox/toxcore/os_system.h",
"tox/toxcore/tox.h",
"tox/toxcore/tox_attributes.h",
"tox/toxcore/tox_log.h",
"tox/toxcore/tox_log_impl.h",
"tox/toxcore/tox_memory.h",
"tox/toxcore/tox_memory_impl.h",
"tox/toxcore/tox_network.h",
"tox/toxcore/tox_network_impl.h",
"tox/toxcore/tox_options.h",
"tox/toxcore/tox_random.h",
"tox/toxcore/tox_random_impl.h",
"tox/toxcore/tox_system.h",
"tox/toxcore/tox_system_impl.h",
"tox/toxcore/tox_time.h",
"tox/toxcore/tox_time_impl.h",
],
cmd = "cp $(locations //c-toxcore/toxcore:public) $(GENDIR)/c-toxcore/tox/toxcore/",
visibility = ["//visibility:public"],
)

genrule(
name = "public_headers",
srcs = [
"toxav.h",
"tox.h",
"toxencryptsave.h",
"//c-toxcore/toxav:toxav.h",
"//c-toxcore/toxcore:tox.h",
"//c-toxcore/toxencryptsave:toxencryptsave.h",
],
outs = [
"tox/toxav.h",
"tox/tox.h",
"tox/toxencryptsave.h",
"tox/toxav/toxav.h",
"tox/toxencryptsave/toxencryptsave.h",
],
cmd = """
cp $(location //c-toxcore/toxav:toxav.h) $(GENDIR)/c-toxcore/tox/toxav.h
cp $(location //c-toxcore/toxcore:tox.h) $(GENDIR)/c-toxcore/tox/tox.h
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h
cp $(location toxav.h) $(GENDIR)/c-toxcore/tox/toxav.h
cp $(location tox.h) $(GENDIR)/c-toxcore/tox/tox.h
cp $(location toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h
cp $(location //c-toxcore/toxav:toxav.h) $(GENDIR)/c-toxcore/tox/toxav/toxav.h
cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave/toxencryptsave.h
""",
visibility = ["//visibility:public"],
)

filegroup(
name = "public",
srcs = [
":public_headers",
":toxcore_headers",
],
visibility = ["//visibility:public"],
)

cc_library(
name = "c-toxcore",
hdrs = [":public_headers"],
hdrs = [":public"],
includes = ["."],
visibility = ["//visibility:public"],
deps = [
Expand Down
50 changes: 48 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ set(toxcore_SOURCES
toxcore/onion_client.c
toxcore/onion_client.h
toxcore/onion.h
toxcore/os_log.c
toxcore/os_log.h
toxcore/os_memory.c
toxcore/os_memory.h
toxcore/os_network.c
toxcore/os_network.h
toxcore/os_network_impl.h
toxcore/os_random.c
toxcore/os_random.h
toxcore/os_system.c
toxcore/os_system.h
toxcore/ping_array.c
toxcore/ping_array.h
toxcore/ping.c
Expand All @@ -302,11 +313,31 @@ set(toxcore_SOURCES
toxcore/timed_auth.h
toxcore/tox_api.c
toxcore/tox.c
toxcore/tox.h
toxcore/tox_dispatch.c
toxcore/tox_dispatch.h
toxcore/tox_events.c
toxcore/tox_events.h
toxcore/tox.h
toxcore/tox_log.c
toxcore/tox_log.h
toxcore/tox_log_impl.h
toxcore/tox_memory.c
toxcore/tox_memory.h
toxcore/tox_memory_impl.h
toxcore/tox_network.c
toxcore/tox_network.h
toxcore/tox_network_impl.h
toxcore/tox_options.c
toxcore/tox_options.h
toxcore/tox_random.c
toxcore/tox_random.h
toxcore/tox_random_impl.h
toxcore/tox_system.c
toxcore/tox_system.h
toxcore/tox_system_impl.h
toxcore/tox_time.c
toxcore/tox_time.h
toxcore/tox_time_impl.h
toxcore/tox_private.c
toxcore/tox_private.h
toxcore/tox_unpack.c
Expand All @@ -316,9 +347,22 @@ set(toxcore_SOURCES
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${LIBSODIUM_LIBRARIES})
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
set(toxcore_API_HEADERS
${toxcore_SOURCE_DIR}/tox.h^tox
${toxcore_SOURCE_DIR}/toxcore/os_log.h^os
${toxcore_SOURCE_DIR}/toxcore/os_memory.h^os
${toxcore_SOURCE_DIR}/toxcore/os_network.h^os
${toxcore_SOURCE_DIR}/toxcore/os_random.h^os
${toxcore_SOURCE_DIR}/toxcore/os_system.h^os
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox)
${toxcore_SOURCE_DIR}/toxcore/tox_log.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_memory.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_network.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_random.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_system.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_time.h^tox)

################################################################################
#
Expand Down Expand Up @@ -346,6 +390,7 @@ if(BUILD_TOXAV)
toxav/video.c
toxav/video.h)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxav.h^toxav
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)

set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
Expand All @@ -362,6 +407,7 @@ set(toxcore_SOURCES ${toxcore_SOURCES}
toxencryptsave/toxencryptsave.c
toxencryptsave/toxencryptsave.h)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxencryptsave.h^tox
${toxcore_SOURCE_DIR}/toxencryptsave/toxencryptsave.h^tox)

################################################################################
Expand Down
5 changes: 5 additions & 0 deletions auto_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cc_library(
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_time",
],
)

Expand Down Expand Up @@ -61,9 +62,13 @@ flaky_tests = {
"//c-toxcore/toxcore:onion",
"//c-toxcore/toxcore:onion_announce",
"//c-toxcore/toxcore:onion_client",
"//c-toxcore/toxcore:os_memory",
"//c-toxcore/toxcore:os_network",
"//c-toxcore/toxcore:os_random",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_dispatch",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:tox_time",
"//c-toxcore/toxcore:util",
"//c-toxcore/toxencryptsave",
"@libsodium",
Expand Down
Loading

0 comments on commit cf46021

Please sign in to comment.