Skip to content

Commit

Permalink
Basic C++ conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
JerwuQu committed Jun 8, 2022
1 parent 32845d7 commit 672e53c
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 272 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ on: [push]
jobs:
build:
name: Ubuntu->Windows Cross Compile
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v1
- name: Install deps
run: sudo apt install gcc-mingw-w64-x86-64
run: |
sudo apt install software-properties-common
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu kinetic universe"
sudo apt update
sudo apt install g++-mingw-w64-x86-64
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
x86_64-w64-mingw32-g++ -v
- name: Build
run: CC=x86_64-w64-mingw32-gcc make
run: make
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: wblocks2
path: wblocks2.exe
- name: Create Release
if: github.ref == 'refs/heads/master'
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -27,6 +34,7 @@ jobs:
draft: false
prerelease: false
- name: Upload release asset
if: github.ref == 'refs/heads/master'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
Expand Down
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/x86_64-w64-mingw32-gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-x64",
"compileCommands": "compile_commands.json"
}
],
"version": 4
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"vector": "cpp",
"*.tcc": "cpp",
"optional": "cpp"
}
}
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
PROJ=wblocks2
SRC=$(wildcard src/*.c)
SRC=$(wildcard src/*.cpp)
DEP=$(wildcard src/*) quickjs

.PHONY: clean clean-all run

DEBUGFLAG=
ifeq ($(DEBUG), 1)
DEBUGFLAG=-DDEBUG
endif

$(PROJ).exe: $(SRC) $(DEP) wblocks.res
x86_64-w64-mingw32-gcc -std=c99 -O2 -Wall -Wl,-subsystem,windows -Iquickjs/include -Lquickjs/lib/quickjs -o $@ $(SRC) wblocks.res -static -lgdi32 -lquickjs -pthread
x86_64-w64-mingw32-g++ $(DEBUGFLAG) -std=c++20 -O2 -Wall -Wl,-subsystem,windows -Iquickjs/include -Lquickjs/lib/quickjs -o $@ $(SRC) wblocks.res -static -lstdc++ -lgdi32 -lquickjs -pthread

wblocks.res:
x86_64-w64-mingw32-windres wblocks.rc -O coff -o wblocks.res
Expand Down
7 changes: 3 additions & 4 deletions src/lib.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ globalThis.setInterval = (fn, interval) => {
};
// TODO: clearInterval

setInterval(__wbc.yieldToC, 10);

globalThis.$quote = arg => {
// Sources:
// - https://stackoverflow.com/a/47469792
Expand Down Expand Up @@ -45,9 +47,6 @@ globalThis.$psFetch = async url => {
return await globalThis.$ps(cmd);
};

setInterval(__wbc.yieldToC, 10);
setInterval(__wbc.checkBarSize, 100);

// TODO: colored info, warn, error
console.error = (...args) => std.err.printf('%s\n', args.join(' '));;

Expand All @@ -71,4 +70,4 @@ files.filter(f => !f.startsWith('.')).sort().forEach(script => {
} catch (ex) {
console.error(`Error running script '${script}':`, ex);
}
});
});
Loading

0 comments on commit 672e53c

Please sign in to comment.