Skip to content

Commit

Permalink
Merge pull request #3 from hardingadonis/feature/cmake
Browse files Browse the repository at this point in the history
Enhance: Implement CMake and more to your project
  • Loading branch information
HaiAu2501 authored Sep 22, 2024
2 parents 14cf30b + 7d53141 commit f95c4ac
Show file tree
Hide file tree
Showing 16 changed files with 445 additions and 187 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write

jobs:
release:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup MSVC Developer Command Prompt
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v5

- name: Build project
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel
cmake --build . --target install --config MinSizeRel
- name: Zip the build
run: |
cd install
7z a ../Operating-System-Project.x64.zip *
- name: GH Release
uses: softprops/action-gh-release@v2
with:
name: Operating-System-Project
tag_name: 1.0.0
files: |
Operating-System-Project.x64.zip
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Ẩn tất cả các file có đuôi .exe (file thực thi)
# *.exe -> Phiên bản mới: Cho phép tải về file thực thi
*.exe

# Ẩn thư mục .vscode
# .vscode/ -> Phiên bản mới: Cho phép tải về thư mục .vscode
.vscode/

# Ẩn file lịch sử và mọi thứ liên quan
history.txt
Expand All @@ -12,4 +12,8 @@ hello.txt
.image/

# Ẩn thư mục Private
Private/
Private/

build/
out/
install/
19 changes: 0 additions & 19 deletions .vscode/c_cpp_properties.json

This file was deleted.

120 changes: 0 additions & 120 deletions .vscode/settings.json

This file was deleted.

29 changes: 0 additions & 29 deletions .vscode/tasks.json

This file was deleted.

19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.10.2)

project(Operating-System-Project VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install")

add_executable(Operating-System-Project main.cpp)
add_definitions(-DNOMINMAX)

install(TARGETS Operating-System-Project RUNTIME DESTINATION .)

add_subdirectory(Process)

install(DIRECTORY Testcase/ DESTINATION Testcase FILES_MATCHING PATTERN "*")

install(DIRECTORY Document/ DESTINATION Document FILES_MATCHING PATTERN "*")
14 changes: 14 additions & 0 deletions Process/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.10.2)

file(GLOB PROCESS_SOURCES *.cpp *.c)

foreach(SOURCE_FILE ${PROCESS_SOURCES})
get_filename_component(EXECUTABLE_NAME ${SOURCE_FILE} NAME_WE)

add_executable(${EXECUTABLE_NAME} ${SOURCE_FILE})
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

install(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION Process)
endforeach()

set_target_properties(countdown PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
Binary file removed Process/child.exe
Binary file not shown.
Binary file removed Process/countdown.exe
Binary file not shown.
Binary file removed Process/counter.exe
Binary file not shown.
16 changes: 15 additions & 1 deletion Process/duck.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <unistd.h>
#include "unistd.h"
#include <string.h>
#include <windows.h>

void clearScreen()
{
Expand Down Expand Up @@ -33,6 +34,19 @@ void printDuck(int position, int quack)
printf("~~~~~~~~~~~~~~~~~~\n");
}

void usleep(unsigned int usec)
{
HANDLE timer;
LARGE_INTEGER ft;

ft.QuadPart = -(10 * (__int64)usec);

timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
}

int main()
{
int width = 80; // Width of the terminal
Expand Down
Binary file removed Process/duck.exe
Binary file not shown.
Binary file removed Process/tictactoe.exe
Binary file not shown.
Loading

0 comments on commit f95c4ac

Please sign in to comment.