Skip to content

Commit 4bd73a0

Browse files
authored
Merge pull request #122 from gucio321/cimgui-updater-v2
makefile: add update rule
2 parents 1a749e7 + 379c8e5 commit 4bd73a0

File tree

108 files changed

+53126
-50722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+53126
-50722
lines changed

.github/workflows/build-lib-linux.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ jobs:
2626
cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/linux/x64
2727
2828
- name: configure cimgui
29-
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DIMGUI_STATIC=On
30-
working-directory: ./cimgui
29+
run: cmake -Bbuild
30+
working-directory: ./lib
3131

3232
- name: make cimgui
3333
run: make
34-
working-directory: ./cimgui/build
34+
working-directory: ./lib/build
3535

3636
- name: copy cimgui to lib
3737
run: |
3838
mkdir -p ./lib/linux/x64
39-
cp -f ./cimgui/build/cimgui.a ./lib/linux/x64/
39+
cp -f ./lib/build/cimgui.a ./lib/linux/x64/
4040
4141
- uses: stefanzweifel/git-auto-commit-action@v4
4242
with:

.github/workflows/build-lib-macos.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,34 @@ jobs:
3939
cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/macos/arm64
4040
4141
- name: configure cimgui for x64
42-
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DIMGUI_STATIC=On -DCMAKE_OSX_ARCHITECTURES=x86_64
43-
working-directory: ./cimgui
42+
run: cmake -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64
43+
working-directory: ./lib
4444

4545
- name: make cimgui for x64
4646
run: make
47-
working-directory: ./cimgui/build
47+
working-directory: ./lib/build
4848

4949
- name: copy cimgui x64 to lib
5050
run: |
5151
mkdir -p ./lib/macos/x64
52-
cp -f ./cimgui/build/cimgui.a ./lib/macos/x64/
52+
cp -f ./lib/build/cimgui.a ./lib/macos/x64/
5353
5454
- name: clean up
5555
run: cmake --build ./build --target clean
56-
working-directory: ./cimgui
56+
working-directory: ./lib
5757

5858
- name: configure cimgui for arm64
59-
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DIMGUI_STATIC=On -DCMAKE_OSX_ARCHITECTURES=arm64
60-
working-directory: ./cimgui
59+
run: cmake -Bbuild -DCMAKE_OSX_ARCHITECTURES=arm64
60+
working-directory: ./lib
6161

6262
- name: make cimgui for arm64
6363
run: make
64-
working-directory: ./cimgui/build
64+
working-directory: ./lib/build
6565

6666
- name: copy cimgui arm64 to lib
6767
run: |
6868
mkdir -p ./lib/macos/arm64
69-
cp -f ./cimgui/build/cimgui.a ./lib/macos/arm64/
69+
cp -f ./lib/build/cimgui.a ./lib/macos/arm64/
7070
7171
- uses: stefanzweifel/git-auto-commit-action@v4
7272
with:

.github/workflows/build-lib-win64.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ jobs:
3737
run: cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/windows/x64
3838

3939
- name: configure cimgui
40-
run: cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DIMGUI_STATIC=On
41-
working-directory: .\cimgui
40+
run: cmake -G Ninja -B build
41+
working-directory: .\lib
4242

4343
- name: make cimgui
4444
run: cmake --build build
45-
working-directory: .\cimgui
45+
working-directory: .\lib
4646

4747
- name: copy cimgui to lib
48-
run: cp -f ./cimgui/build/cimgui.a ./lib/windows/x64/
48+
run: cp -f ./lib/build/cimgui.a ./lib/windows/x64/
4949

5050
- uses: stefanzweifel/git-auto-commit-action@v4
5151
with:

.github/workflows/build-libs.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Compile cimgui for all platforms
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-linux-x64:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@main
12+
13+
- name: add libs for glfw
14+
run: sudo apt install xorg-dev
15+
16+
- name: configure glfw
17+
run: cmake -S . -Bbuild
18+
working-directory: ./thirdparty/glfw
19+
20+
- name: make glfw
21+
run: make
22+
working-directory: ./thirdparty/glfw/build
23+
24+
- name: copy glfw to lib
25+
run: |
26+
cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/linux/x64
27+
28+
- name: configure cimgui
29+
run: cmake -Bbuild
30+
working-directory: ./lib
31+
32+
- name: make cimgui
33+
run: make
34+
working-directory: ./lib/build
35+
36+
- name: copy cimgui to lib
37+
run: |
38+
mkdir -p ./lib/linux/x64
39+
cp -f ./lib/build/cimgui.a ./lib/linux/x64/
40+
41+
- uses: stefanzweifel/git-auto-commit-action@v4
42+
with:
43+
commit_message: Update linux lib from ci
44+
45+
build-windows-x64:
46+
needs: build-linux-x64
47+
runs-on: windows-latest
48+
49+
defaults:
50+
run:
51+
shell: msys2 {0}
52+
53+
steps:
54+
- uses: actions/checkout@main
55+
- run: git pull
56+
- name: Install MinGW
57+
uses: msys2/setup-msys2@v2
58+
with:
59+
update: true
60+
install: >-
61+
make
62+
pacboy: >-
63+
toolchain:p
64+
cmake:p
65+
ninja:p
66+
67+
- name: configure glfw
68+
run: cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release
69+
working-directory: ./thirdparty/glfw
70+
71+
- name: make glfw
72+
run: cmake --build build
73+
working-directory: ./thirdparty/glfw
74+
75+
- name: copy glfw to lib
76+
run: cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/windows/x64
77+
78+
- name: configure cimgui
79+
run: cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DIMGUI_STATIC=On
80+
working-directory: .\lib
81+
82+
- name: make cimgui
83+
run: cmake --build build
84+
working-directory: .\lib
85+
86+
- name: copy cimgui to lib
87+
run: cp -f ./lib/build/cimgui.a ./lib/windows/x64/
88+
89+
- uses: stefanzweifel/git-auto-commit-action@v4
90+
with:
91+
commit_message: Update windows lib from ci
92+
93+
build-macos:
94+
needs: build-windows-x64
95+
runs-on: macos-latest
96+
steps:
97+
- uses: actions/checkout@main
98+
- uses: git-for-windows/setup-git-for-windows-sdk@v1
99+
- run: git pull
100+
shell: bash
101+
- name: configure glfw for x64
102+
run: cmake -S . -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64
103+
working-directory: ./thirdparty/glfw
104+
105+
- name: make glfw x84
106+
run: make
107+
working-directory: ./thirdparty/glfw/build
108+
109+
- name: copy glfw to lib
110+
run: |
111+
cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/macos/x64
112+
113+
- name: clean glfw
114+
run: cmake --build ./build --target clean
115+
working-directory: ./thirdparty/glfw
116+
117+
- name: configure glfw for arm64
118+
run: cmake -S . -Bbuild -DCMAKE_OSX_ARCHITECTURES=arm64
119+
working-directory: ./thirdparty/glfw
120+
121+
- name: make glfw arm64
122+
run: make
123+
working-directory: ./thirdparty/glfw/build
124+
125+
- name: copy glfw to lib
126+
run: |
127+
cp -f ./thirdparty/glfw/build/src/libglfw3.a ./lib/macos/arm64
128+
129+
- name: configure cimgui for x64
130+
run: cmake -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64
131+
working-directory: ./cimgui
132+
133+
- name: make cimgui for x64
134+
run: make
135+
working-directory: ./lib/build
136+
137+
- name: copy cimgui x64 to lib
138+
run: |
139+
mkdir -p ./lib/macos/x64
140+
cp -f ./lib/build/cimgui.a ./lib/macos/x64/
141+
142+
- name: clean up
143+
run: cmake --build ./build --target clean
144+
working-directory: ./cimgui
145+
146+
- name: configure cimgui for arm64
147+
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DIMGUI_STATIC=On -DCMAKE_OSX_ARCHITECTURES=arm64
148+
working-directory: ./cimgui
149+
150+
- name: make cimgui for arm64
151+
run: make
152+
working-directory: ./lib/build
153+
154+
- name: copy cimgui arm64 to lib
155+
run: |
156+
mkdir -p ./lib/macos/arm64
157+
cp -f ./lib/build/cimgui.a ./lib/macos/arm64/
158+
159+
- uses: stefanzweifel/git-auto-commit-action@v4
160+
with:
161+
commit_message: Update macos lib from ci

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ thirdparty/glfw/build
6666
.idea
6767
# Vim cache files
6868
*.swp
69+
70+
# make update temporary directory
71+
tmp

Makefile

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,23 @@ define generate
1919
go run mvdan.cc/gofumpt@latest -w $(1)_funcs.go
2020
endef
2121

22+
define cimgui
23+
$(call generate,cimgui,cimgui/cimgui.h,cimgui/cimgui_templates/definitions.json,cimgui/cimgui_templates/structs_and_enums.json)
24+
endef
25+
2226
## cimgui: generate cimgui binding
2327
.PHONY: cimgui
2428
cimgui:
25-
$(call generate,cimgui,cimgui/cimgui.h,cimgui/generator/output/definitions.json,cimgui/generator/output/structs_and_enums.json)
29+
$(call cimgui)
30+
31+
define cimplot
32+
$(call generate,cimplot,cimgui/cimplot.h,cimgui/cimplot_templates/definitions.json,cimgui/cimplot_templates/structs_and_enums.json,-r cimgui/cimgui_templates/structs_and_enums.json)
33+
endef
2634

2735
## cimplot: generate implot binding
2836
.PHONY: cimplot
2937
cimplot:
30-
$(call generate,cimplot,cimplot/cimplot.h,cimplot/generator/output/definitions.json,cimplot/generator/output/structs_and_enums.json,-r cimgui/generator/output/structs_and_enums.json)
38+
$(call cimplot)
3139

3240
compile_cimgui_macos:
3341
rm -rf ./cimgui/build
@@ -38,3 +46,37 @@ compile_cimgui_macos:
3846
## generate: generates both bindings (equal to `all`)
3947
.PHONY: generate
4048
generate: cimgui cimplot
49+
50+
# update updates sub-repos (like cimplot or cimgui)
51+
# $1 - subrepo directory
52+
# $2 - repository URL
53+
# $3 - $1/<c++ repo>/
54+
define update
55+
@echo "updating $1 from $2"
56+
mkdir -p tmp/
57+
if test -e tmp/$1; then \
58+
rm -rf tmp/*; \
59+
fi
60+
git clone --recurse-submodules $2 tmp/$1
61+
cd tmp/$1/generator; \
62+
sh generator.sh -DIMGUI_USE_WCHAR32
63+
cp tmp/$1/$1* cimgui/
64+
cp tmp/$1/generator/output/$1* cimgui/
65+
mkdir cimgui/$1_templates
66+
cp tmp/$1/generator/output/*json cimgui/$1_templates
67+
mkdir -p cimgui/$3
68+
cp tmp/$1/$3/*cpp cimgui/$3
69+
cp -r tmp/$1/$3/* cimgui/$3
70+
cd tmp/$1; \
71+
echo "$1 ($2) HEAD is on: `git rev-parse HEAD`" >> ../../cimgui/VERSION.txt
72+
cd tmp/$1/$3; \
73+
echo "$1/$3 HEAD is on: `git rev-parse HEAD`" >> ../../../cimgui/VERSION.txt
74+
endef
75+
76+
.PHONY: update
77+
update:
78+
rm -rf cimgui/*
79+
$(call update,cimgui,https://github.com/cimgui/cimgui,imgui)
80+
$(call cimgui)
81+
$(call update,cimplot,https://github.com/cimgui/cimplot,implot)
82+
$(call cimplot)

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ Currently most of the functions are generated, except memory related stuff (eg.
2222
If you find any function is missing, report an issue.
2323

2424
## Generate binding
25-
Install [GNU make](https://www.gnu.org/software/make/manual/make.html)
25+
Install [GNU make](https://www.gnu.org/software/make/manual/make.html) and run `make` to re-generate bunding.
2626

27-
### Update imgui
28-
1. Drop source code of imgui to `cimgui/imgui`.
29-
2. Run `cd cimgui/generator; ./generator.sh`.
30-
3. Run `make cimgui`.
27+
## Update
3128

32-
### Update implot
33-
1. Drop source code of implot to `cimplot/implot`.
34-
2. Run `cd cimplot/generator; ./generator.sh`.
35-
3. Run `make cimplot`.
29+
To update to the latest version of dependencies, run `make update`.
30+
After doing this, commit changes and navigate to GitHub.
31+
In Actions tab, manually trigger workflows for each platform.
3632

33+
## How does it work?
34+
35+
- `cimgui/` directory holds C binding for C++ Dear ImGui libraries
36+
- generator bases on `cimgui/{package_name}_templates` and generates all necessary GO/C code
37+
- `libs/` contains pre-built shared libraries. `cimgui.go` includes and uses to decrease building time.

0 commit comments

Comments
 (0)