Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ if (POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()

if(NOT DAEMON_DIR)
set(DAEMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
get_directory_property(DAEMON_PARENT_SCOPE_DIR PARENT_DIRECTORY)
if (DAEMON_PARENT_SCOPE_DIR)
Expand Down Expand Up @@ -92,12 +96,12 @@ if(NOT DAEMON_EXTERNAL_APP)

if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
# can be loaded by daemon with vm.[sc]game.type 0 or 1
option(BUILD_GAME_NACL "Build the NaCl gamelogic modules, required to host mods." OFF)
option(BUILD_GAME_NACL_NEXE "Build the NaCl \"nexe\" files from the \"pexe\" files." ON)
mark_as_advanced(BUILD_GAME_NACL_NEXE)
option(BUILD_GAME_NACL "Build the NaCl gamelogic modules, required to host mods." OFF)
Comment thread
slipher marked this conversation as resolved.
option(BUILD_GAME_NACL_NEXE "Build the NaCl \"nexe\" files from the \"pexe\" files." ON)
mark_as_advanced(BUILD_GAME_NACL_NEXE)
else()
set(BUILD_GAME_NACL 0)
set(BUILD_GAME_NACL_NEXE 0)
set(BUILD_GAME_NACL OFF)
set(BUILD_GAME_NACL_NEXE OFF)
endif()
option(BUILD_TTY_CLIENT "Engine client with no graphical display" ON)
option(BUILD_DUMMY_APP "Stripped-down engine executable, mostly used to ease incremental porting and debugging" OFF)
Expand Down Expand Up @@ -174,6 +178,13 @@ endif()

include(DaemonPlatform)

if (ARCH STREQUAL "armhf")
if (BUILD_GAME_NACL)
message(WARNING "Building of NaCL \"nexe\" files is not supported on armhf, disabling")
set(BUILD_GAME_NACL OFF CACHE BOOL "Unsupported on armhf" FORCE)
endif()
endif()

################################################################################
# Directories
################################################################################
Expand Down Expand Up @@ -214,12 +225,6 @@ if (NOT NACL)

set(DEPS_EXT ".tar.xz")

if (ARCH STREQUAL "x86_64")
set(DEPS_ARCH amd64)
else()
set(DEPS_ARCH i686)
endif()

if (WIN32)
set(DEPS_SYSTEM windows)
elseif (APPLE)
Expand All @@ -236,7 +241,7 @@ if (NOT NACL)
set(DEPS_COMPILER default)
endif()

set(DEPS_DIR ${EXTERNAL_DEPS_DIR}/${DEPS_SYSTEM}-${DEPS_ARCH}-${DEPS_COMPILER}_${DEPS_VERSION})
set(DEPS_DIR ${EXTERNAL_DEPS_DIR}/${DEPS_SYSTEM}-${ARCH}-${DEPS_COMPILER}_${DEPS_VERSION})

if (DAEMON_PARENT_SCOPE_DIR)
set(DEPS_DIR ${DEPS_DIR} PARENT_SCOPE)
Expand Down Expand Up @@ -911,10 +916,11 @@ if (BUILD_CLIENT OR BUILD_SERVER OR BUILD_TTY_CLIENT)
${DEPS_DIR}/sel_ldr${CMAKE_EXECUTABLE_SUFFIX}
${FULL_OUTPUT_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX}
)

add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/irt_core-${ARCH}.nexe
${FULL_OUTPUT_DIR}/irt_core-${ARCH}.nexe
${DEPS_DIR}/irt_core-${NACL_ARCH}.nexe
${FULL_OUTPUT_DIR}/irt_core-${NACL_ARCH}.nexe
)

# Linux uses a bootstrap program to reserve address space
Expand All @@ -927,7 +933,7 @@ if (BUILD_CLIENT OR BUILD_SERVER OR BUILD_TTY_CLIENT)
endif()

# Win32 requires nacl_loader64.exe in order to run on Win64
if (WIN32 AND ARCH STREQUAL x86)
if (WIN32 AND ARCH STREQUAL i686)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/sel_ldr64${CMAKE_EXECUTABLE_SUFFIX}
Expand Down
19 changes: 14 additions & 5 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ if (MSVC)

set_c_cxx_flag("/W4")

if (ARCH STREQUAL "x86")
if (ARCH STREQUAL "i686")
set_c_cxx_flag("/arch:SSE2")
endif()

if (USE_LTO)
set_c_cxx_flag("/GL" MINSIZEREL)
set_c_cxx_flag("/GL" RELWITHDEBINFO)
Expand Down Expand Up @@ -183,15 +184,21 @@ else()
set_c_cxx_flag("-fno-strict-aliasing")

# Set arch on x86 to SSE2 minimum and enable CMPXCHG16B
if (ARCH STREQUAL "x86")
if (ARCH STREQUAL "i686")
set_c_cxx_flag("-m32")
set_c_cxx_flag("-msse2")
set_c_cxx_flag("-mtune=generic")
try_c_cxx_flag_werror(MFPMATH_SSE "-mfpmath=sse")
elseif (ARCH STREQUAL "x86_64")
elseif (ARCH STREQUAL "amd64")
set_c_cxx_flag("-m64")
set_c_cxx_flag("-mtune=generic")
try_c_cxx_flag_werror(MCX16 "-mcx16")
elseif (ARCH STREQUAL "armhf")
set_c_cxx_flag("-march=armv7")
set_c_cxx_flag("-mfloat-abi=hard")
set_c_cxx_flag("-mfpu=neon")
else()
message(FATAL_ERROR "Unsupported architecture ${ARCH}")
endif()

# Use hidden symbol visibility if possible
Expand Down Expand Up @@ -247,10 +254,12 @@ else()
try_linker_flag(LINKER_PIE "-pie")
if (${FLAG_LINKER_PIE} AND MINGW)
# https://github.com/msys2/MINGW-packages/issues/4100
if (ARCH STREQUAL "x86")
if (ARCH STREQUAL "i686")
set_linker_flag("-Wl,-e,_mainCRTStartup")
else()
elseif(ARCH STREQUAL "amd64")
set_linker_flag("-Wl,-e,mainCRTStartup")
else()
message(FATAL_ERROR "Unsupported architecture ${ARCH}")
endif()
endif()
endif()
Expand Down
21 changes: 12 additions & 9 deletions cmake/DaemonGame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ function(GAMEMODULE)
-DDAEMON_DIR=${Daemon_SOURCE_DIR}
-DDEPS_DIR=${DEPS_DIR}
-DBUILD_GAME_NACL_NEXE=${BUILD_GAME_NACL_NEXE}
-DBUILD_GAME_NACL=1
-DBUILD_GAME_NATIVE_DLL=0
-DBUILD_GAME_NATIVE_EXE=0
-DBUILD_CLIENT=0
-DBUILD_TTY_CLIENT=0
-DBUILD_SERVER=0
-DBUILD_GAME_NACL_NEXE_ARMHF=${BUILD_GAME_NACL_NEXE_ARMHF}
-DBUILD_GAME_NACL=ON
Comment thread
slipher marked this conversation as resolved.
-DBUILD_GAME_NATIVE_DLL=OFF
-DBUILD_GAME_NATIVE_EXE=OFF
-DBUILD_CLIENT=OFF
-DBUILD_TTY_CLIENT=OFF
-DBUILD_SERVER=OFF
${inherited_option_args}
INSTALL_COMMAND ""
)
Expand Down Expand Up @@ -119,9 +120,11 @@ function(GAMEMODULE)
ADD_PRECOMPILED_HEADER(${GAMEMODULE_NAME}-nacl)

if (BUILD_GAME_NACL_NEXE)
# Generate NaCl executables for x86 and x86_64
pnacl_translate(${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${GAMEMODULE_NAME} i686 "-x86")
pnacl_translate(${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${GAMEMODULE_NAME} x86-64 "-x86_64")
# Generate NaCl executables for supported architectures.
# TODO(0.54): Unify all arch strings using i686 and amd64 strings.
pnacl_translate(${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${GAMEMODULE_NAME} "i686" "x86")
pnacl_translate(${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${GAMEMODULE_NAME} "x86-64" "x86_64")
pnacl_translate(${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${GAMEMODULE_NAME} "arm" "armhf")
endif()
endif()
endfunction()
40 changes: 27 additions & 13 deletions cmake/DaemonNacl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,35 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Native client
if( APPLE )
add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_OSX=1 )
elseif( LINUX )
add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_ANDROID=0 -DNACL_OSX=0 )
elseif( WIN32 )
add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_OSX=0 )
endif()
if( ARCH STREQUAL "x86" OR ARCH STREQUAL "x86_64" )

if( NACL )
# Build nexe binary.
# Those defines looks to be meaningless to produce arch-independent pexe,
# but they must be set to anything supported by native builds. this
# requirement looks to be a NaCl bug.
add_definitions( -DNACL_BUILD_ARCH=x86 )
else()
add_definitions( -DNACL_BUILD_ARCH=${ARCH} )
endif()
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
add_definitions( -DNACL_BUILD_SUBARCH=64 )
else()
add_definitions( -DNACL_BUILD_SUBARCH=32 )
# Build native dll or native exe.
if( APPLE )
add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_OSX=1 )
elseif( LINUX )
add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_ANDROID=0 -DNACL_OSX=0 )
elseif( WIN32 )
add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_OSX=0 )
endif()

if( ARCH STREQUAL "amd64" )
add_definitions( -DNACL_BUILD_ARCH=x86 )
add_definitions( -DNACL_BUILD_SUBARCH=64 )
elseif( ARCH STREQUAL "i686" )
add_definitions( -DNACL_BUILD_ARCH=x86 )
add_definitions( -DNACL_BUILD_SUBARCH=32 )
elseif( ARCH STREQUAL "armhf" )
add_definitions( -DNACL_BUILD_ARCH=arm )
else()
message(FATAL_ERROR "Unsupported architecture ${ARCH}")
endif()
endif()

include_directories( ${LIB_DIR}/nacl )
11 changes: 1 addition & 10 deletions cmake/DaemonPlatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,4 @@ else()
message( FATAL_ERROR "Platform not supported" )
endif()

################################################################################
# Determine architecture
################################################################################

# When adding a new architecture, look at all the places ARCH is used
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( ARCH "x86_64" )
else()
set( ARCH "x86" )
endif()
include("${DAEMON_DIR}/tools/DaemonArchitecture/DaemonArchitecture.cmake")
16 changes: 8 additions & 8 deletions cmake/toolchain-pnacl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,26 @@ set(NACL_TRANSLATE_OPTIONS
$<$<CONFIG:MinSizeRel>:-O2>
)

function(pnacl_translate dir module arch suffix)
function(pnacl_translate dir module nacl_option arch)
set(PEXE ${dir}/${module}.pexe)
set(NEXE ${dir}/${module}${suffix}.nexe)
set(STRIPPED_NEXE ${dir}/${module}${suffix}-stripped.nexe)
set(NEXE ${dir}/${module}-${arch}.nexe)
set(STRIPPED_NEXE ${dir}/${module}-${arch}-stripped.nexe)

add_custom_command(
OUTPUT ${NEXE}
COMMENT "Translating ${target} (${arch})"
COMMENT "Translating ${module} (${arch})"
DEPENDS ${PEXE}
COMMAND
${PNACLPYTHON_PREFIX2}
"${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-translate${PNACL_BIN_EXT}"
${NACL_TRANSLATE_OPTIONS}
-arch ${arch}
-arch ${nacl_option}
${PEXE}
-o ${NEXE}
)
add_custom_command(
OUTPUT ${STRIPPED_NEXE}
COMMENT "Stripping ${target} (${arch})"
COMMENT "Stripping ${module} (${arch})"
DEPENDS ${NEXE}
COMMAND
${PNACLPYTHON_PREFIX2}
Expand All @@ -131,6 +131,6 @@ function(pnacl_translate dir module arch suffix)
-o ${STRIPPED_NEXE}
)

add_custom_target(${module}${suffix} ALL DEPENDS ${STRIPPED_NEXE})
add_dependencies(${module}${suffix} ${module}-nacl)
add_custom_target(${module}-${arch} ALL DEPENDS ${STRIPPED_NEXE})
add_dependencies(${module}-${arch} ${module}-nacl)
endfunction()
Loading