Skip to content

Rename CMake options, prefix with QJS_ #897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,28 @@ jobs:
if [ "${{ matrix.config.configType }}" = "Debug" ]; then
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV;
elif [ "${{ matrix.config.configType }}" = "examples" ]; then
echo "BUILD_EXAMPLES=ON" >> $GITHUB_ENV;
echo "QJS_BUILD_EXAMPLES=ON" >> $GITHUB_ENV;
elif [ "${{ matrix.config.configType }}" = "shared" ]; then
echo "BUILD_SHARED_LIBS=ON" >> $GITHUB_ENV;
elif [ "${{ matrix.config.configType }}" = "asan+ubsan" ]; then
echo "BUILD_TYPE=RelWithDebInfo" >> $GITHUB_ENV;
echo "CONFIG_ASAN=ON" >> $GITHUB_ENV;
echo "CONFIG_UBSAN=ON" >> $GITHUB_ENV;
echo "QJS_ENABLE_ASAN=ON" >> $GITHUB_ENV;
echo "QJS_ENABLE_UBSAN=ON" >> $GITHUB_ENV;
elif [ "${{ matrix.config.configType }}" = "msan" ]; then
echo "BUILD_TYPE=RelWithDebInfo" >> $GITHUB_ENV;
echo "CONFIG_MSAN=ON" >> $GITHUB_ENV;
echo "QJS_ENABLE_MSAN=ON" >> $GITHUB_ENV;
echo "CC=clang" >> $GITHUB_ENV;
fi

- name: build
run: |
make \
BUILD_TYPE=$BUILD_TYPE \
BUILD_EXAMPLES=$BUILD_EXAMPLES \
QJS_BUILD_EXAMPLES=$QJS_BUILD_EXAMPLES \
BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
CONFIG_ASAN=$CONFIG_ASAN \
CONFIG_UBSAN=$CONFIG_UBSAN \
CONFIG_MSAN=$CONFIG_MSAN
QJS_ENABLE_ASAN=$QJS_ENABLE_ASAN \
QJS_ENABLE_UBSAN=$QJS_ENABLE_UBSAN \
QJS_ENABLE_MSAN=$QJS_ENABLE_MSAN

- name: stats
if: ${{ matrix.config.configType != 'examples' }}
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
- uses: actions/checkout@v4
- name: build
run: |
cmake -B build -DBUILD_EXAMPLES=ON -G "Visual Studio 17 2022" -A ${{matrix.arch}}
cmake -B build -DQJS_BUILD_EXAMPLES=ON -G "Visual Studio 17 2022" -A ${{matrix.arch}}
cmake --build build --config ${{matrix.buildType}}
- name: stats
run: |
Expand Down Expand Up @@ -226,7 +226,7 @@ jobs:
- uses: actions/checkout@v4
- name: build
run: |
cmake -B build -DBUILD_EXAMPLES=ON -G "Visual Studio 16 2019" -A ${{matrix.arch}}
cmake -B build -DQJS_BUILD_EXAMPLES=ON -G "Visual Studio 16 2019" -A ${{matrix.arch}}
cmake --build build --config ${{matrix.buildType}} --target qjs_exe
- name: stats
run: |
Expand All @@ -251,7 +251,7 @@ jobs:
- name: build
run: |
git submodule update --init --checkout --depth 1
cmake -B build -DBUILD_EXAMPLES=ON -G "Visual Studio 17 2022" -T ClangCL
cmake -B build -DQJS_BUILD_EXAMPLES=ON -G "Visual Studio 17 2022" -T ClangCL
cmake --build build --config ${{matrix.buildType}}
- name: stats
run: |
Expand Down Expand Up @@ -287,7 +287,7 @@ jobs:
- name: build
run: |
git submodule update --init --checkout --depth 1
cmake -B build -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -G "Ninja"
cmake -B build -DQJS_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -G "Ninja"
cmake --build build
- name: stats
run: |
Expand Down Expand Up @@ -320,7 +320,7 @@ jobs:
features: 'OptionId.DesktopCPPx86,OptionId.DesktopCPPx64'
- name: build
run: |
cmake -B build -DBUILD_EXAMPLES=ON -DCMAKE_SYSTEM_VERSION="10.0.26100.0" -A ${{matrix.arch}}
cmake -B build -DQJS_BUILD_EXAMPLES=ON -DCMAKE_SYSTEM_VERSION="10.0.26100.0" -A ${{matrix.arch}}
cmake --build build --config ${{matrix.buildType}}
- name: stats
run: |
Expand Down Expand Up @@ -423,7 +423,7 @@ jobs:
run: emcc -v
- name: build
run: |
emcmake cmake -B build -DBUILD_QJS_LIBC=ON
emcmake cmake -B build -DQJS_BUILD_LIBC=ON
emmake make -C build qjs_wasm -j$(getconf _NPROCESSORS_ONLN)
- name: result
run: ls -lh build
Expand Down Expand Up @@ -515,7 +515,7 @@ jobs:
run: |
mkdir build
cd build
$ANDROID_HOME/cmake/3.22.1/bin/cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/26.0.10792818/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-24 -DBUILD_QJS_LIBC=ON ..
$ANDROID_HOME/cmake/3.22.1/bin/cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/26.0.10792818/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-24 -DQJS_BUILD_LIBC=ON ..
- name: Build android arm64
run: |
$ANDROID_HOME/cmake/3.22.1/bin/cmake --build build --target qjs
Expand All @@ -527,7 +527,7 @@ jobs:
- uses: actions/checkout@v4
- name: configure
run: |
cmake -B build -GXcode -DCMAKE_SYSTEM_NAME:STRING=iOS -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED:BOOL=NO -DBUILD_QJS_LIBC=ON
cmake -B build -GXcode -DCMAKE_SYSTEM_NAME:STRING=iOS -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED:BOOL=NO -DQJS_BUILD_LIBC=ON
- name: build
run: |
cmake --build build --config Release --target qjs
Expand All @@ -536,7 +536,7 @@ jobs:
mimalloc-linux:
runs-on: ubuntu-24.04
env:
BUILD_CLI_WITH_MIMALLOC: ON
QJS_BUILD_CLI_WITH_MIMALLOC: ON
MIMALLOC_SHOW_STATS: 1
steps:
- uses: actions/checkout@v4
Expand All @@ -556,7 +556,7 @@ jobs:
mimalloc-macos:
runs-on: macos-latest
env:
BUILD_CLI_WITH_STATIC_MIMALLOC: ON
QJS_BUILD_CLI_WITH_STATIC_MIMALLOC: ON
MIMALLOC_SHOW_STATS: 1
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DBUILD_STATIC_QJS_EXE=ON ..
cmake -DQJS_BUILD_CLI_STATIC=ON ..
cd ..
cmake --build build --target qjs_exe -j$(getconf _NPROCESSORS_ONLN)
cmake --build build --target qjsc -j$(getconf _NPROCESSORS_ONLN)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
submodules: true
- name: build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONFIG_TSAN=ON
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DQJS_ENABLE_TSAN=ON
cmake --build build -j`nproc`
- name: test
run: |
Expand Down
46 changes: 23 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ if(BUILD_SHARED_LIBS)
message(STATUS "Building a shared library")
endif()

# note: CONFIG_TSAN is currently incompatible with the other sanitizers but we
# note: QJS_ENABLE_TSAN is currently incompatible with the other sanitizers but we
# don't explicitly check for that because who knows what the future will bring?
# CONFIG_MSAN only works with clang at the time of writing; also not checked
# QJS_ENABLE_MSAN only works with clang at the time of writing; also not checked
# for the same reason
xoption(BUILD_EXAMPLES "Build examples" OFF)
xoption(BUILD_STATIC_QJS_EXE "Build a static qjs executable" OFF)
xoption(BUILD_CLI_WITH_MIMALLOC "Build the qjs executable with mimalloc" OFF)
xoption(BUILD_CLI_WITH_STATIC_MIMALLOC "Build the qjs executable with mimalloc (statically linked)" OFF)
xoption(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF)
xoption(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF)
xoption(CONFIG_TSAN "Enable ThreadSanitizer (TSan)" OFF)
xoption(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)

if(CONFIG_ASAN)
xoption(QJS_BUILD_EXAMPLES "Build examples" OFF)
xoption(QJS_BUILD_CLI_STATIC "Build a static qjs executable" OFF)
xoption(QJS_BUILD_CLI_WITH_MIMALLOC "Build the qjs executable with mimalloc" OFF)
xoption(QJS_BUILD_CLI_WITH_STATIC_MIMALLOC "Build the qjs executable with mimalloc (statically linked)" OFF)
xoption(QJS_ENABLE_ASAN "Enable AddressSanitizer (ASan)" OFF)
xoption(QJS_ENABLE_MSAN "Enable MemorySanitizer (MSan)" OFF)
xoption(QJS_ENABLE_TSAN "Enable ThreadSanitizer (TSan)" OFF)
xoption(QJS_ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)

if(QJS_ENABLE_ASAN)
message(STATUS "Building with ASan")
add_compile_options(
-fsanitize=address
Expand All @@ -137,7 +137,7 @@ add_link_options(
)
endif()

if(CONFIG_MSAN)
if(QJS_ENABLE_MSAN)
message(STATUS "Building with MSan")
add_compile_options(
-fsanitize=memory
Expand All @@ -151,7 +151,7 @@ add_link_options(
)
endif()

if(CONFIG_TSAN)
if(QJS_ENABLE_TSAN)
message(STATUS "Building with TSan")
add_compile_options(
-fsanitize=thread
Expand All @@ -165,7 +165,7 @@ add_link_options(
)
endif()

if(CONFIG_UBSAN)
if(QJS_ENABLE_UBSAN)
message(STATUS "Building with UBSan")
add_compile_options(
-fsanitize=undefined
Expand All @@ -183,14 +183,14 @@ endif()
# QuickJS library
#

xoption(BUILD_QJS_LIBC "Build standard library modules as part of the library" OFF)
xoption(QJS_BUILD_LIBC "Build standard library modules as part of the library" OFF)
macro(add_qjs_libc_if_needed target)
if(NOT BUILD_QJS_LIBC)
if(NOT QJS_BUILD_LIBC)
target_sources(${target} PRIVATE quickjs-libc.c)
endif()
endmacro()
macro(add_static_if_needed target)
if(BUILD_STATIC_QJS_EXE OR MINGW)
if(QJS_BUILD_CLI_STATIC OR MINGW)
target_link_options(${target} PRIVATE -static)
if(MINGW)
target_link_options(${target} PRIVATE -static-libgcc)
Expand All @@ -206,7 +206,7 @@ set(qjs_sources
quickjs.c
)

if(BUILD_QJS_LIBC)
if(QJS_BUILD_LIBC)
list(APPEND qjs_sources quickjs-libc.c)
endif()
list(APPEND qjs_defines _GNU_SOURCE)
Expand Down Expand Up @@ -282,10 +282,10 @@ target_link_libraries(qjs_exe qjs)
if(NOT WIN32)
set_target_properties(qjs_exe PROPERTIES ENABLE_EXPORTS TRUE)
endif()
if(BUILD_CLI_WITH_MIMALLOC OR BUILD_CLI_WITH_STATIC_MIMALLOC)
if(QJS_BUILD_CLI_WITH_MIMALLOC OR QJS_BUILD_CLI_WITH_STATIC_MIMALLOC)
find_package(mimalloc REQUIRED)
# Upstream mimalloc doesn't provide a way to know if both libraries are supported.
if(BUILD_CLI_WITH_STATIC_MIMALLOC)
if(QJS_BUILD_CLI_WITH_STATIC_MIMALLOC)
target_link_libraries(qjs_exe mimalloc-static)
else()
target_link_libraries(qjs_exe mimalloc)
Expand Down Expand Up @@ -334,7 +334,7 @@ target_link_libraries(function_source qjs)
# Examples
#

if(BUILD_EXAMPLES)
if(QJS_BUILD_EXAMPLES)
add_executable(hello
gen/hello.c
)
Expand Down Expand Up @@ -399,7 +399,7 @@ if(NOT IOS)
SOVERSION ${QJS_VERSION_MAJOR}
)
install(FILES quickjs.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(BUILD_QJS_LIBC)
if(QJS_BUILD_LIBC)
install(FILES quickjs-libc.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
install(TARGETS qjs_exe RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down