Skip to content

Commit 6665a6a

Browse files
committed
Switch to building with CMake.
1 parent e3f2637 commit 6665a6a

File tree

8 files changed

+207
-276
lines changed

8 files changed

+207
-276
lines changed

.github/workflows/release.yml

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,88 @@ on:
66
description: Optional release tag (normally auto-detected)
77

88
jobs:
9-
build:
9+
get-version:
1010
runs-on: ubuntu-latest
11-
container: ghcr.io/orbitalquark/textadept-build:v1.0
1211
outputs:
13-
version: ${{ steps.build.outputs.version }}
12+
version: ${{ steps.get-version.outputs.version }}
1413
steps:
1514
- name: Checkout
16-
uses: actions/checkout@v2
17-
- name: Git init if necessary
18-
shell: bash
15+
uses: actions/checkout@v4
16+
17+
- name: Get version
18+
id: get-version
1919
run: |
20-
# If git version is less than 2.18, a git clone will not be made in this container. In
21-
# that case, make a temporary repository so "make release" can archive the repo's
22-
# contents for release.
23-
if [[ -d .git ]]; then exit 0; fi
24-
git init
25-
git add .
26-
git config --global user.email "none@example.com"
27-
git config --global user.name "none"
28-
git commit -m 'none'
20+
version="${{ github.event.inputs.tag }}"
21+
if [[ -z "$version" ]]; then
22+
version=`grep -m1 '###' docs/changelog.md | cut -d ' ' -f 2`
23+
fi
24+
echo "version=$version" >> "$GITHUB_OUTPUT"
25+
26+
build:
27+
strategy:
28+
matrix:
29+
os: [ubuntu-20.04, windows-2019]
30+
runs-on: ${{ matrix.os }}
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
2935
- name: Checkout textadept-build dependencies
30-
uses: actions/checkout@v2
36+
uses: actions/checkout@v4
3137
with:
3238
repository: orbitalquark/textadept-build
3339
path: textadept-build
40+
3441
- name: Build
35-
id: build
3642
shell: bash
3743
run: |
38-
# Move cached dependencies into current dir.
39-
mv textadept-build/* .
40-
rm -r textadept-build
44+
# Move cached dependencies into build/_deps.
45+
mkdir -p build/_deps && mv textadept-build/* build/_deps && rm -r textadept-build
4146
4247
# Build.
43-
make deps docs
44-
make release
48+
cmake -S . -B build
49+
cmake --build build --config Release
50+
cmake --install build
4551
46-
# Output version information for use in later steps.
47-
version="${{ github.event.inputs.tag }}"
48-
if [[ -z $version ]]; then
49-
version=`ls -1 scintillua_*.zip | head -1 | sed 's/[^_]\+_\(.\+\)\.zip/\1/;'`
50-
fi
51-
echo "::set-output name=version::$version"
5252
- name: Upload artifacts
5353
uses: actions/upload-artifact@v4
5454
with:
55-
name: artifacts
55+
name: artifacts-${{ matrix.os }}
5656
path: |
57-
scintillua_*
58-
docs/changelog.md
59-
tag:
57+
lexers/*.so
58+
lexers/*.dll
59+
60+
release:
6061
runs-on: ubuntu-latest
61-
needs: build
62+
needs: [get-version, build]
6263
steps:
6364
- name: Checkout
6465
uses: actions/checkout@v4
65-
- name: Tag
66-
run: |
67-
git tag scintillua_${{ needs.build.outputs.version }}
68-
git push -f origin scintillua_${{ needs.build.outputs.version }}
69-
release:
70-
runs-on: ubuntu-latest
71-
needs: [build, tag]
72-
steps:
66+
with:
67+
path: scintillua
68+
7369
- name: Download artifacts
7470
uses: actions/download-artifact@v4
7571
with:
76-
name: artifacts
72+
path: scintillua/lexers
73+
merge-multiple: true
74+
75+
- name: Generate HTML documentation
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install lua5.4 discount --no-install-recommends -y
79+
cd scintillua && ./gen_docs.sh
80+
81+
- name: Tag
82+
if: github.ref_name == github.event.repository.default_branch
83+
run: |
84+
git tag scintillua_${{ needs.get-version.outputs.version }}
85+
git push -f origin scintillua_${{ needs.get-version.outputs.version }}
86+
7787
- name: Create release log
78-
shell: bash
7988
run: |
8089
echo -n "Scintillua " > log.md
81-
echo -n "${{ needs.build.outputs.version }} " >> log.md
90+
echo -n "${{ needs.get-version.outputs.version }} " >> log.md
8291
echo \(`date +"%d %b %Y"`\) >> log.md
8392
prefix="https://orbitalquark.github.io/scintillua"
8493
echoing=0
@@ -92,13 +101,26 @@ jobs:
92101
elif [[ $echoing -eq 1 ]]; then
93102
echo "$line" | sed "s,\(manual\|api\)\.html,$prefix/\0,;"
94103
fi
95-
done < docs/changelog.md >> log.md
104+
done < scintillua/docs/changelog.md >> log.md
105+
106+
- name: Generate archive
107+
run: zip -r scintillua_${{ needs.get-version.outputs.version }}.zip scintillua
108+
109+
- name: Upload artifacts
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: artifacts-release
113+
path: |
114+
log.md
115+
scintillua_${{ needs.get-version.outputs.version }}.zip
116+
96117
- name: Create release
118+
if: github.ref_name == github.event.repository.default_branch
97119
uses: ncipollo/release-action@v1
98120
with:
99121
name: ${{ needs.build.outputs.version }}
100122
tag: scintillua_${{ needs.build.outputs.version }}
101123
allowUpdates: true
102124
bodyFile: log.md
103-
artifacts: scintillua_*
125+
artifacts: scintillua_${{ needs.get-version.outputs.version }}.zip
104126
token: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2025 Mitchell. See LICENSE.
2+
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
if(APPLE)
8+
set(CMAKE_OSX_DEPLOYMENT_TARGET 11 CACHE STRING "")
9+
endif()
10+
11+
set(src ${CMAKE_SOURCE_DIR})
12+
13+
project(scintillua LANGUAGES C CXX)
14+
15+
# Dependencies.
16+
include(FetchContent)
17+
set(FETCHCONTENT_QUIET OFF)
18+
set(deps_dir ${CMAKE_BINARY_DIR}/_deps)
19+
function(fetch name url)
20+
string(REGEX MATCH "[^/]+$" archive ${url})
21+
if(EXISTS ${deps_dir}/${archive})
22+
set(url file://${deps_dir}/${archive}) # use local archive instead of downloading
23+
endif()
24+
FetchContent_Declare(${name} URL ${url})
25+
# Note: cannot FetchContent_MakeAvailable(${name}) here, as name must be a literal.
26+
endfunction()
27+
fetch(scintilla https://www.scintilla.org/scintilla501.tgz)
28+
fetch(lexilla https://www.scintilla.org/lexilla510.tgz)
29+
fetch(lua http://www.lua.org/ftp/lua-5.3.5.tar.gz) # needs to be same X.Y as SciTE
30+
fetch(lpeg http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.1.0.tar.gz)
31+
FetchContent_MakeAvailable(scintilla lexilla lua lpeg)
32+
set(FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE BOOL "Do not update deps if already set up")
33+
34+
# Scintilla.
35+
# Nothing to set up.
36+
37+
# Lexilla.
38+
add_library(lexilla STATIC)
39+
set(lexilla_src lexlib/PropSetSimple.cxx lexlib/Accessor.cxx lexlib/DefaultLexer.cxx)
40+
list(TRANSFORM lexilla_src PREPEND ${lexilla_SOURCE_DIR}/)
41+
target_sources(lexilla PRIVATE ${lexilla_src})
42+
target_include_directories(lexilla PUBLIC ${scintilla_SOURCE_DIR}/include
43+
${lexilla_SOURCE_DIR}/include ${lexilla_SOURCE_DIR}/lexlib)
44+
target_compile_definitions(lexilla PUBLIC SCI_LEXER)
45+
set_property(TARGET lexilla PROPERTY POSITION_INDEPENDENT_CODE ON)
46+
47+
# Lua.
48+
add_library(lua STATIC)
49+
file(GLOB lua_src ${lua_SOURCE_DIR}/src/*.c)
50+
list(FILTER lua_src EXCLUDE REGEX
51+
"(lua|luac|lbitlib|lcorolib|ldblib|liolib|loadlib|loslib|linit)\.c$")
52+
target_include_directories(lua PUBLIC ${lua_SOURCE_DIR}/src)
53+
target_sources(lua PRIVATE ${lua_src})
54+
target_compile_definitions(lua PRIVATE $<$<CONFIG:Debug>:LUA_USE_APICHECK>)
55+
set_property(TARGET lua PROPERTY POSITION_INDEPENDENT_CODE ON)
56+
57+
# LPeg.
58+
add_library(lpeg STATIC)
59+
file(GLOB lpeg_src ${lpeg_SOURCE_DIR}/*.c)
60+
target_sources(lpeg PRIVATE ${lpeg_src})
61+
target_link_libraries(lpeg PRIVATE lua)
62+
set_property(TARGET lpeg PROPERTY POSITION_INDEPENDENT_CODE ON)
63+
64+
# Scintillua.
65+
set(scintillua_src ${src}/Scintillua.cxx)
66+
add_library(scintillua SHARED ${scintillua_src})
67+
target_link_libraries(scintillua PRIVATE lexilla lua lpeg)
68+
69+
# Install.
70+
install(TARGETS scintillua DESTINATION ${src}/lexers)

0 commit comments

Comments
 (0)