Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
chore: CMakeLists: change executable name using `set_target_propertie…
Browse files Browse the repository at this point in the history
…s()`

Signed-off-by: Ookiineko <[email protected]>
  • Loading branch information
Ookiineko committed Apr 11, 2024
1 parent 4b7cbe9 commit bafeda5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 48 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.magiskboot.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# partially copied from Magisk

corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/Magisk/native/src/Cargo.toml
CRATES magiskboot_rs)
CRATES magiskboot)
if (RUSTFLAGS)
corrosion_add_target_rustflags(magiskboot_rs ${RUSTFLAGS})
corrosion_add_target_rustflags(magiskboot ${RUSTFLAGS})
endif()
if (CARGO_FLAGS)
corrosion_set_cargo_flags(magiskboot_rs ${CARGO_FLAGS})
corrosion_set_cargo_flags(magiskboot ${CARGO_FLAGS})
endif()
corrosion_set_env_vars(magiskboot_rs
corrosion_set_env_vars(magiskboot
CXXBRIDGE_GEN_TARGET_OS=${CXXBRIDGE_GEN_TARGET_OS}
RUSTC_BOOTSTRAP=${RUSTC_BOOTSTRAP})

add_custom_target(workspace_cleanup
COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_SOURCE_DIR}/src/Magisk/native/src/.cargo/config.toml
COMMENT "Cleaning up workspace")
add_dependencies(_cargo-build_magiskboot_rs workspace_cleanup)
add_dependencies(_cargo-build_magiskboot workspace_cleanup)

add_library(libbase STATIC
src/Magisk/native/src/base/files.cpp
Expand All @@ -24,7 +24,7 @@ add_library(libbase STATIC
src/Magisk/native/src/base/stream.cpp
src/Magisk/native/src/external/cxx-rs/src/cxx.cc
src/magiskbase-rs-wrapper.cc)
add_dependencies(libbase magiskboot_rs-static)
add_dependencies(libbase magiskboot-static)
target_compile_definitions(libbase PRIVATE -DRUST_CXX_NO_EXCEPTIONS)
add_dependencies(libbase prepared_generated_directory)
target_include_directories(libbase PRIVATE
Expand Down Expand Up @@ -68,18 +68,18 @@ target_include_directories(libzopfli PUBLIC
target_compile_options(libzopfli PRIVATE
-Werror -Wno-unused -Wno-unused-parameter)

add_executable(${MAGISKBOOT_TARGET}
add_executable(magiskboot_exe
src/Magisk/native/src/boot/main.cpp
src/Magisk/native/src/boot/bootimg.cpp
src/Magisk/native/src/boot/compress.cpp
src/Magisk/native/src/boot/format.cpp
src/magiskboot-rs-wrapper.cc)
add_dependencies(${MAGISKBOOT_TARGET} magiskboot_rs-static)
target_include_directories(${MAGISKBOOT_TARGET} PRIVATE
add_dependencies(magiskboot_exe magiskboot-static)
target_include_directories(magiskboot_exe PRIVATE
src/Magisk/native/src/external/cxx-rs/include)
target_link_libraries(${MAGISKBOOT_TARGET}
target_link_libraries(magiskboot_exe
libbase
magiskboot_rs-static
magiskboot-static
LibLZMA::LibLZMA
PkgConfig::liblz4
BZip2::BZip2
Expand All @@ -88,4 +88,4 @@ target_link_libraries(${MAGISKBOOT_TARGET}
Threads::Threads)

include(GNUInstallDirs)
install(TARGETS ${MAGISKBOOT_TARGET} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS magiskboot_exe DESTINATION ${CMAKE_INSTALL_BINDIR})
4 changes: 2 additions & 2 deletions CMakeLists.stub.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if (WIN32)
target_link_libraries(platform_stubs INTERFACE shlwapi)

# these source files contains symbols that must not be excluded from the final executable
target_sources(${MAGISKBOOT_TARGET} PRIVATE
target_sources(magiskboot_exe PRIVATE
src/libc-compat/winsup/crt_flags.c)

add_library(libmman STATIC
Expand Down Expand Up @@ -113,4 +113,4 @@ if (EMSCRIPTEN)
endif()

target_link_libraries(libbase platform_stubs)
target_link_libraries(${MAGISKBOOT_TARGET} platform_stubs)
target_link_libraries(magiskboot_exe platform_stubs)
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option(WITH_LIBCXX "Link libcxx instead of libstdc++" ON)
option(FULL_RUST_LTO "Keep LLVM bitcode in Rust libraries for LTO (requires LLD)" OFF)
set(RUSTFLAGS "" CACHE STRING "extra flags passed to rustc")
set(CARGO_FLAGS "" CACHE STRING "extra flags passed to cargo")
set(RUSTC_BOOTSTRAP "winsup,base,magiskboot_rs" CACHE STRING "")
set(RUSTC_BOOTSTRAP "winsup,base,magiskboot" CACHE STRING "")

# useful for cross-compiling
option(RUST_BUILD_STD "Build Rust standard library" OFF)
Expand Down Expand Up @@ -70,14 +70,6 @@ if (NOT WITHOUT_BUILD)
endif()
endif()

if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(MAGISKBOOT_TARGET magiskboot_debug)
message(STATUS "Debug (unoptimized) build")
else()
set(MAGISKBOOT_TARGET magiskboot)
message(STATUS "Release (optimized) build")
endif()

include(CMakeLists.compat.txt)

find_package(PkgConfig REQUIRED)
Expand Down Expand Up @@ -114,6 +106,15 @@ if (NOT WITHOUT_BUILD)

include(CMakeLists.rust.txt)
include(CMakeLists.magiskboot.txt)

if (CMAKE_BUILD_TYPE MATCHES "Debug")
set_target_properties(magiskboot_exe PROPERTIES OUTPUT_NAME "magiskboot_debug")
message(STATUS "Debug (unoptimized) build")
else()
set_target_properties(magiskboot_exe PROPERTIES OUTPUT_NAME "magiskboot")
message(STATUS "Release (optimized) build")
endif()

include(CMakeLists.stub.txt)
endif()

Expand Down
25 changes: 0 additions & 25 deletions patches/Magisk/0001-native-fix-header-includes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,6 @@ index 114b55c..0b6e3c0 100644
codegen-units = 1
-panic = "abort"

diff --git a/native/src/Cargo.lock b/native/src/Cargo.lock
index 4b60785..a03a476 100644
--- a/native/src/Cargo.lock
+++ b/native/src/Cargo.lock
@@ -478,7 +478,7 @@ dependencies = [
]

[[package]]
-name = "magiskboot"
+name = "magiskboot_rs"
version = "0.0.0"
dependencies = [
"argh",
diff --git a/native/src/boot/Cargo.toml b/native/src/boot/Cargo.toml
index e3e0d30..c5ecb43 100644
--- a/native/src/boot/Cargo.toml
+++ b/native/src/boot/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "magiskboot"
+name = "magiskboot_rs"
version = "0.0.0"
edition = "2021"


diff --git a/native/src/base/files.cpp b/native/src/base/files.cpp
index 6829de2..8aef651 100644
--- a/native/src/base/files.cpp
Expand Down

0 comments on commit bafeda5

Please sign in to comment.