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 13, 2024
1 parent d4cc76d commit aeee6b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-11, macos-12]
os: [macos-14, macos-13, macos-12]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@main
- uses: actions/checkout@4

- run: brew update
- run: brew install --overwrite python@3.10 python@3.11
Expand Down Expand Up @@ -132,17 +132,17 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [macos-11, macos-12]
version: [macos-14, macos-13, macos-12]

runs-on: ${{ matrix.version }}

steps:
- run: brew update
- run: brew install cmake ninja pkg-config

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: microsoft/vcpkg
path: vcpkg
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [macos-11, macos-12]
version: [macos-14, macos-13, macos-12, macos-11]

runs-on: ${{ matrix.version }}

Expand All @@ -259,9 +259,9 @@ jobs:
- run: brew install --overwrite python@3.10 python@3.11
- run: brew install cmake ninja llvm pkg-config

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: microsoft/vcpkg
path: vcpkg
Expand Down Expand Up @@ -371,12 +371,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-11, macos-12]
os: [macos-14, macos-13, macos-12, macos-11]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@main
- uses: actions/checkout@4

- run: brew update
- run: brew install --overwrite python@3.10 python@3.11
Expand Down
27 changes: 13 additions & 14 deletions src/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -6513,23 +6513,22 @@ static int try_compile(const char * compilerFilePath, const char * compilerOptio
}
}

static int check_if_compiler_support_Wno_error_unused_command_line_argument(const char * sessionDIR, const size_t sessionDIRLength, const char * compiler, const bool iscc, const char * ccflags, const char * ldflags) {
static int check_if_compiler_support_Wno_error_unused_command_line_argument(const char * sessionDIR, const size_t sessionDIRLength, const char * compiler, const bool iscxx, const char * ccflags, const char * ldflags) {
size_t testCFilePathCapacity = sessionDIRLength + 10U;
char testCFilePath[testCFilePathCapacity];

int ret;

if (iscc) {
ret = snprintf(testCFilePath, testCFilePathCapacity, "%s/test.c", sessionDIR);
} else {
ret = snprintf(testCFilePath, testCFilePathCapacity, "%s/test.cc", sessionDIR);
}
int ret = snprintf(testCFilePath, testCFilePathCapacity, "%s/test.c", sessionDIR);

if (ret < 0) {
perror(NULL);
return PPKG_ERROR;
}

if (iscxx) {
testCFilePath[ret] = 'c';
testCFilePath[ret + 1] = '\0';
}

int fd = open(testCFilePath, O_CREAT | O_TRUNC | O_WRONLY, 0666);

if (fd == -1) {
Expand All @@ -6556,17 +6555,17 @@ static int check_if_compiler_support_Wno_error_unused_command_line_argument(cons
return PPKG_ERROR;
}

size_t compilerOptionCapacity = strlen(ccflags) + strlen(ldflags) + 42U;
char compilerOption[compilerOptionCapacity];
size_t cmdCapacity = strlen(compiler) + strlen(ccflags) + strlen(ldflags) + testCFilePathCapacity + 45U;
char cmd[cmdCapacity];

ret = snprintf(compilerOption, compilerOptionCapacity, "-Wno-error=unused-command-line-argument %s %s" , ccflags, ldflags);
ret = snprintf(cmd, cmdCapacity, "%s -Wno-error=unused-command-line-argument %s %s %s", compiler, ccflags, ldflags, testCFilePath);

if (ret < 0) {
perror(NULL);
return PPKG_ERROR;
}

return try_compile(compiler, compilerOption, testCFilePath);
return run_cmd(cmd, STDOUT_FILENO);
}

int ppkg_setup_toolchain_for_native_build(
Expand Down Expand Up @@ -6660,8 +6659,8 @@ int ppkg_setup_toolchain_for_native_build(

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

int ret1 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cc, true, toolchainForNativeBuild->ccflags, toolchainForNativeBuild->ldflags);
int ret2 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cxx, true, toolchainForNativeBuild->cxxflags, toolchainForNativeBuild->ldflags);
int ret1 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cc, false, toolchainForNativeBuild->ccflags, toolchainForNativeBuild->ldflags);
int ret2 = check_if_compiler_support_Wno_error_unused_command_line_argument(sessionDIR, sessionDIRLength, toolchainForNativeBuild->cxx, true, toolchainForNativeBuild->cxxflags, toolchainForNativeBuild->ldflags);

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

Expand Down

0 comments on commit aeee6b0

Please sign in to comment.