Skip to content

Commit

Permalink
ver: bump to 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenvukhang committed Feb 1, 2023
2 parents 01284fa + f8698e1 commit a5363da
Show file tree
Hide file tree
Showing 53 changed files with 221 additions and 37,807 deletions.
121 changes: 87 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ permissions:
contents: write

env:
QT_SRC_DIR: ~/Qt/git/src
QT_STATIC_DIR: ~/Qt/git/output
QT_STATIC_DIR: Qt/static

# Standard format of uploaded asset:
# CanvasSync-${{ github.ref_name }}-${{ matrix.os }}.{app,exe,deb}

jobs:
build:
mac:
strategy:
fail-fast: false
matrix:
Expand All @@ -28,45 +30,31 @@ jobs:
version: 6.4.2
runs-on: ${{ matrix.os }}
steps:
# end of experiments
- run: echo "ASSET=CanvasSync-${{ matrix.os }}.tar.gz">>$GITHUB_ENV
if: startsWith(matrix.os, 'windows') == false
- run: |
echo "ASSET=CanvasSync-${{ matrix.os }}.tar.gz">>$env:GITHUB_ENV
Add-Content $env:GITHUB_PATH 'C:/ProgramData/Chocolatey/bin'
Add-Content $env:GITHUB_PATH 'C:/Strawberry/perl/bin'
Add-Content $env:GITHUB_PATH 'C:/hostedtoolcache/windows/Ruby/2.5.9/x64/bin'
Add-Content $env:GITHUB_PATH 'C:/hostedtoolcache/windows/Python/3.7.9/x64/bin'
Add-Content $env:GITHUB_PATH 'C:/Program Files/CMake/bin'
Add-Content $env:GITHUB_PATH 'C:/ProgramData/chocolatey/lib/zstandard/tools'
Add-Content $env:GITHUB_PATH 'C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin'
choco install ninja mingw zstandard
if: startsWith(matrix.os, 'windows')
- name: Set environment variables
run: |
echo "ASSET=CanvasSync-${{ github.ref_name }}-${{ matrix.os }}.dmg" >>$GITHUB_ENV
echo "QT_STATIC_DIR=$PWD/${{ env.QT_STATIC_DIR }}" >>$GITHUB_ENV
- uses: actions/checkout@v3

# download pre-build static Qt libraries
- run: |
curl -fLo qt_static.tar.gz https://github.com/nguyenvukhang/qt-static/releases/download/v0.0.18/qt-${{ matrix.version }}-${{ matrix.os }}.tar.gz
- name: download pre-build static Qt libraries
run: |
curl -fLo qt.tar.gz https://github.com/nguyenvukhang/qt-static/releases/download/v0.0.18/qt-${{ matrix.version }}-${{ matrix.os }}.tar.gz
mkdir -p ${{ env.QT_STATIC_DIR }}
tar -xvzf qt_static.tar.gz && mv qt_output/* ${{ env.QT_STATIC_DIR }}
- run: xattr -cr ${{ env.QT_STATIC_DIR }}
if: startsWith(matrix.os, 'macos')
tar -xvzf qt.tar.gz && mv qt_output/* ${{ env.QT_STATIC_DIR }}
# build canvas-sync
- run: cmake -DQT_STATIC_DIR=${{ env.QT_STATIC_DIR }} -DCMAKE_BUILD_TYPE=Release -S . -B build
if: startsWith(matrix.os, 'windows') == false
- run: cmake -DQT_STATIC_DIR=${{ env.QT_STATIC_DIR }} -DCMAKE_BUILD_TYPE=Release -S . -B build -G 'MinGW Makefiles'
if: startsWith(matrix.os, 'windows')

- run: cmake --build build
- run: make build

# package app
- run: cd build && tar -zcvf ${{ env.ASSET }} CanvasSync.app && mv ${{ env.ASSET }} ..
if: startsWith(matrix.os, 'macos')
- run: cd build && tar -zcvf ${{ env.ASSET }} CanvasSync.exe && mv ${{ env.ASSET }} ..
if: startsWith(matrix.os, 'windows')
- run: |
mkdir dmg
cp -a build/CanvasSync.app dmg/CanvasSync.app
ln -s /Applications dmg/Applications
hdiutil create -volname CanvasSync \
-srcfolder dmg \
-fs HFS+ -ov -format UDBZ \
${{ env.ASSET }}
# upload release package
- name: Release
Expand All @@ -75,3 +63,68 @@ jobs:
with:
files: ${{ env.ASSET }}
generate_release_notes: true

win:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
version: 6.4.2
- os: windows-2022
version: 6.4.2
runs-on: ${{ matrix.os }}
steps:
- name: Set environment variables
shell: bash
run: |
echo "ASSET=CanvasSync-${{ github.ref_name }}-${{ matrix.os }}.exe" >>$GITHUB_ENV
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
arch: win64_msvc2019_64
version: ${{ matrix.version }}
tools: tools_ifw

- name: Install MSVC 2022
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Install build dependencies
shell: bash
run: cinst -y ninja

- uses: actions/checkout@v3

- name: Build
run: |
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build -G Ninja `
-DCMAKE_PREFIX_PATH=${{ env.Qt6_DIR }}
cmake --build build
- name: Use windeployqt to load libraries
shell: bash
run: |
mv build/CanvasSync.exe \
deploy/windows/packages/com.nguyenvukhang.canvassync/data
cd deploy/windows/packages/com.nguyenvukhang.canvassync/data
$Qt6_DIR/bin/windeployqt.exe CanvasSync.exe
- name: Package the installer
shell: bash
run: |
cd deploy/windows
$IQTA_TOOLS/QtInstallerFramework/4.5/bin/binarycreator.exe \
-c config/config.xml -p packages CanvasSyncInstaller-${{ matrix.os }}.exe
mv CanvasSyncInstaller-${{ matrix.os }}.exe ../..
# upload release package
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
CanvasSyncInstaller-${{ matrix.os }}.exe
generate_release_notes: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash

Expand Down Expand Up @@ -78,3 +77,4 @@ CMakeLists.txt.user*
/compile_commands.json
build/
build.qt/
/Qt
36 changes: 20 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ message(STATUS "RECEIVED QT_STATIC type: ${QT_STATIC_DIR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) # to build compile_commands.json
# note that CMAKE_PREFIX_PATH must contain a Qt directory. Meaning that
# if you `ls` on this directory then stuff like bin/ and include/ shows
set(CMAKE_PREFIX_PATH ${QT_STATIC_DIR})
if (EXISTS ${QT_STATIC_DIR})
set(CMAKE_PREFIX_PATH ${QT_STATIC_DIR})
endif()

# auto-generated flags
set(CMAKE_AUTOUIC ON)
Expand All @@ -17,20 +19,18 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS Widgets Network)

set(PROJECT_SOURCES
main.cc
mainwindow.cc mainwindow.h mainwindow.ui
updates.cc updates.h updates.ui
tree_model.h
tree_model.cc
convert.h
convert.cc
clickable_tree_view.h
clickable_tree_view.cc
tree.h
tree.cc
tree_model.h tree_model.cc
convert.h convert.cc
clickable_tree_view.h clickable_tree_view.cc
tree.h tree.cc
filetree.h filetree.cc
types.h types.cc
)

# include the autogen stuff so ui files can be imported
Expand All @@ -44,22 +44,26 @@ include_directories(
option(BUILD_STATIC_LIBS ON)
option(BUILD_SHARED_LIBS OFF)

if(WIN32)
set(APP_ICON_WINDOWS "${CMAKE_CURRENT_SOURCE_DIR}/appicon.rc")
set(PROJECT_SOURCES ${PROJECT_SOURCES} ${APP_ICON_WINDOWS})
elseif(APPLE)
set(APP_ICON_MACOS "${CMAKE_CURRENT_SOURCE_DIR}/deploy/canvas-sync.icns")
set_source_files_properties(${APP_ICON_MACOS} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(PROJECT_SOURCES ${PROJECT_SOURCES} ${APP_ICON_MACOS})
endif()

qt_add_executable(CanvasSync MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(CanvasSync PRIVATE Qt6::Widgets Qt6::Network)
set_target_properties(CanvasSync PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER canvassync.nguyenvukhang.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE_ICON_FILE canvas-sync.icns
MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE
)
install(TARGETS CanvasSync
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

# pull in the canvas server library
add_subdirectory(csrv)
target_link_libraries(CanvasSync PUBLIC CanvasServer)

qt_finalize_executable(CanvasSync)

include(CPack)
33 changes: 20 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(dir $(MAKEFILE_PATH))

QT_STATIC_DIR ?= $(MAKEFILE_DIR)/Qt/static
QT_SRC_DIR ?= $(MAKEFILE_DIR)/Qt/src

QT_CFG_ARGS := -opensource -release -static -nomake examples -nomake tests -skip qt3d -skip qttranslations -skip qt5compat -skip qtactiveqt -skip qtcharts -skip qtcoap -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qthttpserver -skip qtlanguageserver -skip qtlottie -skip qtmqtt -skip qtmultimedia -skip qtnetworkauth -skip qtopcua -skip qtpositioning -skip qtquick3d -skip qtquick3dphysics -skip qtquicktimeline -skip qtremoteobjects -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtshadertools -skip qtspeech -skip qtsvg -skip qttools -skip qtwebsockets
QT_STATIC_DIR ?= ~/_Qt_/git/output
QT_SRC_DIR ?= ~/_Qt_/git/src
QT_INIT_ARGS := --module-subset=qtbase
QT_VERSION ?= 6.2.0

main:
@make --no-print-directory build
Expand All @@ -12,21 +18,22 @@ build: FORCE
-S . -B build
cmake --build build # alternatively: cd build && make

inspect:
otool -L ./build/CanvasSync.app/Contents/MacOS/CanvasSync
build-win: FORCE
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build -G Ninja
cmake --build build

qt-setup:
make clone-qt
make init-qt

open:
open ./build/CanvasSync.app
clone-qt:
git clone https://code.qt.io/qt/qt5.git -b v$(QT_VERSION) $(QT_SRC_DIR)

get-qt:
mkdir -p $(QT_SRC_DIR)
@if [ ! -f $(QT_SRC_DIR)/configure ]; then \
git clone https://code.qt.io/qt/qt5.git -b v$(QT_VERSION) $(QT_SRC_DIR); \
cd $(QT_SRC_DIR) && ./init-repository -f --module-subset=qtbase; \
fi
init-qt:
cd $(QT_SRC_DIR) && perl init-repository $(QT_INIT_ARGS)

config-qt:
cd $(QT_SRC_DIR) && ./configure $(QT_CFG_ARGS) -prefix $(QT_STATIC_DIR)
cd $(QT_SRC_DIR) && ./configure -prefix $(QT_STATIC_DIR) $(QT_CFG_ARGS)

clean-qt:
cd $(QT_SRC_DIR) && ninja clean
Expand Down
30 changes: 3 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
# installing qt from scratch
# Canvas Sync

## requirements

git, ninja

## get the repo

[instructions](https://wiki.qt.io/Building_Qt_6_from_Git)
```
git clone https://code.qt.io/qt/qt5.git qt6
git switch v6.4.2
./init-repository --module-subset=qtbase,qtshadertools,qtdeclarative
```

## build

```sh
mkdir qt6-build
cd qt6-build
../qt6/configure -prefix /path/to/install
cmake --build . --parallel 4
cmake --install .
```

in particular, I ran `../qt6/configure -static`

to get static libraries
A tool for students to keep local folders in sync with remote folders
on Canvas.
Binary file added appicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions appicon.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "appicon.ico"
3 changes: 2 additions & 1 deletion convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ File to_file(const QJsonObject &j)
File f;
f.id = j["id"].toInt(BAD_ID);
f.folder_id = j["folder_id"].toInt();
f.filename = j["filename"].toString().toStdString();
f.filename = j["display_name"].toString().toStdString();
f.filename = normalize_filename(&f.filename);
f.url = j["url"].toString().toStdString();
return f;
}
Expand Down
70 changes: 0 additions & 70 deletions csrv/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit a5363da

Please sign in to comment.