Skip to content

withgraphite's plutil

beerpsi edited this page May 12, 2022 · 1 revision

I decided against static compilation for this one since the resulting binary is absolutely massive, and the suite is actually two binaries, plutil and PlistBuddy.

Dependencies

Clone the repo, install ninja, cmake, gcc, libxml2 for your target

Patching CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c9c6f13..94588e56 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,7 +62,7 @@ endif ()
 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
   add_compile_options(/D_CRT_SECURE_NO_WARNINGS) # TODO: /Wall /WX
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-  add_compile_options(-Wall -Werror)
+  add_compile_options(-Wall -Werror -Wno-address-of-packed-member)
   if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
     add_compile_options(-Wno-multichar -Wno-sign-compare)
   endif ()

Building

As you would do any typical CMake project:

mkdir build && cd build
cmake ..
ninja

Since we're not static compiling, there are a few things that needs to be bundled in the final zip distribution:

$ ldd plutil.exe | grep /c/Users | cut -d' ' -f1
        libutil.dll
        libstdc++-6.dll
        libplist.dll
        libstdc++-6.dll
        libprocess.dll
        libgcc_s_seh-1.dll
        libwinpthread-1.dll

Static building

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c9c6f13..ee2abf97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,8 @@ project(xcbuild C CXX)
 cmake_minimum_required(VERSION 3.0)
 cmake_policy(SET CMP0054 NEW)

-set(BUILD_SHARED_LIBS True CACHE BOOL "Build shared libraries." FORCE)
+set(BUILD_SHARED_LIBS False CACHE BOOL "Build shared libraries." FORCE)
+set(CMAKE_EXE_LINKER_FLAGS "-static")

 # Platform options.
 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
Clone this wiki locally