Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
Signed-off-by: leleliu008 <leleliu008@gmail.com>
  • Loading branch information
leleliu008 committed Mar 17, 2024
1 parent 5face79 commit 2adc156
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 18 deletions.
44 changes: 30 additions & 14 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ jobs:
- uses: actions/checkout@v4

- run: brew update
- run: brew install --overwrite python@3.10 python@3.11
#- run: brew install --overwrite python@3.10 python@3.11 python@3.12
- run: brew install cmake ninja pkg-config curl sqlite jansson libyaml libgit2 libarchive

- run: sed -i '.bak' '/Requires.private:/d' "$(brew --prefix libarchive)/lib/pkgconfig/libarchive.pc"

- run: |
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig"
CMAKE_EXE_LINKER_FLAGS='-L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -lssl -liconv -framework CoreFoundation -framework Security'
CMAKE_FIND_ROOT_PATH="$(brew --prefix openssl@1.1);$(brew --prefix curl);$(brew --prefix sqlite);$(brew --prefix libarchive)"
HOMEBREW_PREFIX="$(brew --prefix)"
export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig"
export CMAKE_EXE_LINKER_FLAGS="-L$HOMEBREW_PREFIX/lib -lssl -liconv -framework CoreFoundation -framework Security"
export CMAKE_FIND_ROOT_PATH="$HOMEBREW_PREFIX"
for PKG in curl libarchive sqlite
do
PKG_INSTALLED_DIR="$(brew --prefix "$PKG")"
PKG_CONFIG_PATH="$PKG_CONFIG_PATH $PKG_INSTALLED_DIR/lib/pkgconfig"
CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -L$PKG_INSTALLED_DIR/lib"
CMAKE_FIND_ROOT_PATH="$CMAKE_FIND_ROOT_PATH $PKG_INSTALLED_DIR"
done
cmake \
-S . \
Expand Down Expand Up @@ -279,7 +287,7 @@ jobs:
-DCMAKE_INSTALL_PREFIX=./output \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_C_FLAGS="-fsanitize=undefined -fsanitize=address -fsanitize=leak"
- run: cmake --build build.d
Expand Down Expand Up @@ -379,15 +387,23 @@ jobs:
- uses: actions/checkout@v4

- run: brew update
- run: brew install --overwrite python@3.10 python@3.11
#- run: brew install --overwrite python@3.10 python@3.11 python@3.12
- run: brew install cmake ninja llvm pkg-config curl sqlite jansson libyaml libgit2 libarchive

- run: sed -i '.bak' '/Requires.private:/d' "$(brew --prefix libarchive)/lib/pkgconfig/libarchive.pc"

- run: |
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig"
CMAKE_EXE_LINKER_FLAGS='-L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -lssl -liconv -framework CoreFoundation -framework Security'
CMAKE_FIND_ROOT_PATH="$(brew --prefix openssl@1.1);$(brew --prefix curl);$(brew --prefix sqlite);$(brew --prefix libarchive)"
HOMEBREW_PREFIX="$(brew --prefix)"
export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig"
export CMAKE_EXE_LINKER_FLAGS="-L$HOMEBREW_PREFIX/lib -lssl -liconv -framework CoreFoundation -framework Security"
export CMAKE_FIND_ROOT_PATH="$HOMEBREW_PREFIX"
for PKG in curl libarchive sqlite
do
PKG_INSTALLED_DIR="$(brew --prefix "$PKG")"
PKG_CONFIG_PATH="$PKG_CONFIG_PATH $PKG_INSTALLED_DIR/lib/pkgconfig"
CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -L$PKG_INSTALLED_DIR/lib"
CMAKE_FIND_ROOT_PATH="$CMAKE_FIND_ROOT_PATH $PKG_INSTALLED_DIR"
done
cmake \
-S . \
Expand All @@ -398,7 +414,7 @@ jobs:
-DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" \
-DCMAKE_FIND_ROOT_PATH="$CMAKE_FIND_ROOT_PATH" \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_C_FLAGS="-fsanitize=undefined -fsanitize=address -fsanitize=leak"
- run: cmake --build build.d
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,24 @@ cmake --install build.d

```bash
brew update
brew install git cmake pkg-config ninja curl jansson libyaml libgit2 libarchive zlib
brew install git cmake ninja pkg-config curl jansson libyaml libgit2 libarchive

git clone --depth=1 --branch=c https://github.com/leleliu008/ppkg
cd ppkg

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig"
HOMEBREW_PREFIX="$(brew --prefix)"

CMAKE_EXE_LINKER_FLAGS='-L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -lssl -liconv -framework CoreFoundation -framework Security'
CMAKE_FIND_ROOT_PATH="$(brew --prefix openssl@1.1);$(brew --prefix curl);$(brew --prefix libarchive)"
export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig"
export CMAKE_EXE_LINKER_FLAGS="-L$HOMEBREW_PREFIX/lib -lssl -liconv -framework CoreFoundation -framework Security"
export CMAKE_FIND_ROOT_PATH="$HOMEBREW_PREFIX"

for PKG in curl libarchive sqlite
do
PKG_INSTALLED_DIR="$(brew --prefix "$PKG")"
PKG_CONFIG_PATH="$PKG_CONFIG_PATH $PKG_INSTALLED_DIR/lib/pkgconfig"
CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -L$PKG_INSTALLED_DIR/lib"
CMAKE_FIND_ROOT_PATH="$CMAKE_FIND_ROOT_PATH $PKG_INSTALLED_DIR"
done

cmake \
-S . \
Expand Down
11 changes: 11 additions & 0 deletions src/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -4827,6 +4827,17 @@ static int ppkg_install_package(

//////////////////////////////////////////////////////////////////////////////

const char* unsetenvs2[] = { "ZLIB_CFLAGS", "ZLIB_LIBS", "BZIP2_CFLAGS", "BZIP2_LIBS", "LIBLZMA_CFLAGS", "LIBLZMA_LIBS", "LIBSQLITE3_CFLAGS", "LIBSQLITE3_LIBS", "GDBM_CFLAGS", "GDBM_LIBS", "LIBS", "PKG_CONFIG_PATH", NULL };

for (int i = 0; unsetenvs2[i] != NULL; i++) {
if (unsetenv(unsetenvs2[i]) != 0) {
perror(unsetenvs2[i]);
return PPKG_ERROR;
}
}

//////////////////////////////////////////////////////////////////////////////

const bool isTargetOSDarwin = strcmp(targetPlatform->name, "macos") == 0;

if (isTargetOSDarwin) {
Expand Down

0 comments on commit 2adc156

Please sign in to comment.