Skip to content

Commit

Permalink
cmake: Sync upstream changes
Browse files Browse the repository at this point in the history
Signed-off-by: sekaiacg <[email protected]>
  • Loading branch information
sekaiacg committed Jun 3, 2023
1 parent fe60d3f commit 30e0a01
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
6 changes: 4 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ cmake_build()
-DANDROID_ABI="$ABI" \
-DANDROID_STL="c++_static" \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake" \
-DANDROID_USE_LEGACY_TOOLCHAIN_FILE="OFF"
-DANDROID_USE_LEGACY_TOOLCHAIN_FILE="OFF" \
-DMAX_BLOCK_SIZE="4096"
elif [[ $TARGET == "Linux" ]]; then
local LINUX_PLATFORM=$4
local WSL="OFF"
Expand All @@ -37,7 +38,8 @@ cmake_build()
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_CXX_COMPILER="clang++" \
-DENABLE_FULL_LTO="ON"
-DENABLE_FULL_LTO="ON" \
-DMAX_BLOCK_SIZE="4096"
fi

${MAKE_CMD}
Expand Down
17 changes: 17 additions & 0 deletions build/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ add_definitions(
"-D_LARGEFILE64_SOURCE"
)

if (NOT MAX_BLOCK_SIZE)
try_run(CHECK_MAX_BLOCK_SIZE_RESULT
CHECK_MAX_BLOCK_SIZE_COMPILE_RESULT
${CMAKE_CURRENT_BINARY_DIR}/sources
${CMAKE_CURRENT_SOURCE_DIR}/sources/checkMaxBlockSize.c
NO_CACHE
RUN_OUTPUT_VARIABLE erofs_cv_max_block_size
)
if (erofs_cv_max_block_size GREATER 0)
add_definitions(-DEROFS_MAX_BLOCK_SIZE=${erofs_cv_max_block_size})
else ()
add_definitions(-DEROFS_MAX_BLOCK_SIZE=4096)
endif ()
else ()
add_definitions(-DEROFS_MAX_BLOCK_SIZE=${MAX_BLOCK_SIZE})
endif ()

# Compile flags
set(GLOBAL_CFLAGS
"-Wformat"
Expand Down
10 changes: 10 additions & 0 deletions build/cmake/sources/checkMaxBlockSize.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <unistd.h>
#include <stdio.h>

int main(int argc, char **argv) {
int result = sysconf(_SC_PAGESIZE);
if (result < 0)
return 1;
printf("%d", result);
return 0;
}
3 changes: 2 additions & 1 deletion build_darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ cmake_build()
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_C_COMPILER="clang" \
-DCMAKE_CXX_COMPILER="clang++" \
-DENABLE_FULL_LTO="ON"
-DENABLE_FULL_LTO="ON" \
-DMAX_BLOCK_SIZE="4096"
fi

${MAKE_CMD}
Expand Down

0 comments on commit 30e0a01

Please sign in to comment.