Skip to content

Commit

Permalink
Flex cmake (#3352)
Browse files Browse the repository at this point in the history
* [CMake] generate FLEX files.
[CI] add Flex in prerequires.
[Doc] Add Flex as prerequires.

* Restore CodeLite/include_finder.l which generates CodeLite/include_finder.cpp
  • Loading branch information
Jarod42 committed May 14, 2024
1 parent fa49efd commit b7e7f14
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 13,512 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Codelite's dependencies
run: |
# brew update && brew upgrade # fails somehow
brew install git cmake libssh hunspell
brew install git cmake libssh hunspell flex
# WxWidgets
- name: Checkout
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: |
# pacman -Syu --noconfirm # Fail, requires to close this process
pacman -S --noconfirm mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-make mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-clang-tools-extra
pacman -S --noconfirm mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libssh mingw-w64-clang-x86_64-hunspell mingw-w64-clang-x86_64-openssl mingw-w64-clang-x86_64-sqlite3
pacman -S --noconfirm mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-libssh mingw-w64-clang-x86_64-hunspell mingw-w64-clang-x86_64-openssl mingw-w64-clang-x86_64-sqlite3 flex
# WxWidgets
- name: Checkout
Expand All @@ -34,7 +34,7 @@ jobs:
run: |
mkdir wxWidgets/build-release
cd wxWidgets/build-release
PATH="/clang64/bin:$PATH" cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/root -DwxBUILD_DEBUG_LEVEL=0 -DwxBUILD_MONOLITHIC=1 -DwxBUILD_SAMPLES=SOME -DwxUSE_STL=1
PATH="/clang64/bin:$PATH" cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$HOME/root" -DwxBUILD_DEBUG_LEVEL=0 -DwxBUILD_MONOLITHIC=1 -DwxBUILD_SAMPLES=SOME -DwxUSE_STL=1
PATH="/clang64/bin:$PATH" mingw32-make -j$(nproc) && PATH="/clang64/bin:$PATH" mingw32-make install
# wx-config-msys2
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
mkdir build-release
cd build-release
MSYS2_BASE=/d/a/_temp/msys64 PATH="/clang64/bin:$HOME/root/bin:$PATH" cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DWXWIN=$HOME/root -Wno-dev
MSYS2_BASE=/d/a/_temp/msys64 PATH="/clang64/bin:$HOME/root/bin:$PATH" cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DWXWIN="$HOME/root" -Wno-dev
PATH="/clang64/bin:$HOME/root/bin:$PATH" mingw32-make -j$(nproc) install
# Upload artefact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# Codelite
- name: install Codelite's dependencies
run: sudo apt-get install build-essential cmake git libpcre2-dev libsqlite3-dev libssh-dev
run: sudo apt-get install build-essential cmake git libpcre2-dev libsqlite3-dev libssh-dev flex

- name: Checkout Codelite
uses: actions/checkout@v4
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,24 @@ if(NOT SQLite3_FOUND)
" **** Could not find sqlite3. Please install sqlite3 package: pacman -S mingw-w64-clang-x86_64-sqlite3"
)
else()
message(FATAL_ERROR " **** Could not find sqlite3. Plesae install sqlite3 development package")
message(FATAL_ERROR " **** Could not find sqlite3. Please install sqlite3 development package")
endif()
endif()

find_package(FLEX REQUIRED)

if(NOT FLEX_FOUND)
if(UNIX)
message(FATAL_ERROR " **** Could not find flex. Please install flex package")
elseif(APPLE)
message(FATAL_ERROR " **** Could not find flex. Please install flex via brew")
elseif(MINGW)
message(
FATAL_ERROR
" **** Could not find flex. Please install flex package: pacman -S flex"
)
else()
message(FATAL_ERROR " **** Could not find flex. Please install flex package")
endif()
endif()

Expand Down
47 changes: 11 additions & 36 deletions CodeLite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,16 @@ if(UNIX AND NOT APPLE)
endif(UNIX AND NOT APPLE)

# Flex files
if(UNIX AND NOT APPLE)
if(WITH_FLEX)
message("-- Adding flex support")
find_package(FLEX REQUIRED)

set(CxxFlexOutput ${CMAKE_SOURCE_DIR}/CodeLite/CxxLexer.cpp)
set(CxxFlexInput ${CMAKE_SOURCE_DIR}/CodeLite/CxxScanner.l)

set(PhpFlexOutput ${CMAKE_SOURCE_DIR}/CodeLite/PhpLexer.cpp)
set(PhpFlexInput ${CMAKE_SOURCE_DIR}/CodeLite/PhpLexer.l)

set(JSFlexOutput ${CMAKE_SOURCE_DIR}/CodeLite/JSLexer.cpp)
set(JSFlexInput ${CMAKE_SOURCE_DIR}/CodeLite/JSLexer.l)

if(FLEX_FOUND)
add_custom_command(
OUTPUT ${CxxFlexOutput}
COMMAND ${FLEX_EXECUTABLE} --noline --yylineno --batch --outfile=${CxxFlexOutput} ${CxxFlexInput}
DEPENDS ${CxxFlexInput}
COMMENT "Generating ${CxxFlexOutput}")
add_custom_command(
OUTPUT ${PhpFlexOutput}
COMMAND ${FLEX_EXECUTABLE} -Pphp --yylineno --noline --batch --outfile=${PhpFlexOutput} ${PhpFlexInput}
DEPENDS ${PhpFlexInput}
COMMENT "Generating ${PhpFlexOutput}")
add_custom_command(
OUTPUT ${JSFlexOutput}
COMMAND ${FLEX_EXECUTABLE} -Pjs --yylineno --noline --batch --outfile=${JSFlexOutput} ${JSFlexInput}
DEPENDS ${JSFlexInput}
COMMENT "Generating ${JSFlexOutput}")
endif()
else()
message("-- Flex support is disabled")
endif()
endif()
FLEX_TARGET(CxxFlex "${CMAKE_SOURCE_DIR}/CodeLite/CxxScanner.l" "${CMAKE_CURRENT_BINARY_DIR}/CxxScanner.cpp"
COMPILE_FLAGS "--noline --yylineno --batch")
FLEX_TARGET(IncludeFinderFlex "${CMAKE_SOURCE_DIR}/CodeLite/include_finder.l" "${CMAKE_CURRENT_BINARY_DIR}/include_finder.cpp"
COMPILE_FLAGS "-Pinclf_ --noline --yylineno --batch")
FLEX_TARGET(PhpFlex "${CMAKE_SOURCE_DIR}/CodeLite/PhpLexer.l" "${CMAKE_CURRENT_BINARY_DIR}/PhpLexer.cpp"
COMPILE_FLAGS "-Pphp --noline --yylineno --batch")
FLEX_TARGET(XmlFlex "${CMAKE_SOURCE_DIR}/CodeLite/XMLLexer.l" "${CMAKE_CURRENT_BINARY_DIR}/XmlLexer.cpp"
COMPILE_FLAGS "-Pxml --noline --yylineno --batch")

set(FlexSrcs "${FLEX_CxxFlex_OUTPUTS}" "${FLEX_IncludeFinderFlex_OUTPUTS}" "${FLEX_PhpFlex_OUTPUTS}" "${FLEX_XmlFlex_OUTPUTS}")

# Include paths
include_directories(
Expand Down Expand Up @@ -122,7 +97,7 @@ else()
endif()

# Define the output
add_library(libcodelite SHARED ${SRCS})
add_library(libcodelite SHARED ${SRCS} ${FlexSrcs})
target_link_libraries(
libcodelite
${LINKER_OPTIONS}
Expand Down

0 comments on commit b7e7f14

Please sign in to comment.