Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr0x committed Jun 14, 2023
2 parents affc12b + 0a35740 commit 7794d48
Show file tree
Hide file tree
Showing 14 changed files with 894 additions and 93 deletions.
7 changes: 0 additions & 7 deletions .github/release.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: build app
name: Test CMake app

on:
push:
paths:
- "**.cpp"
- "**.h"
- "CMakeLists.txt"
- "**.cmake"
pull_request:
paths:
- "**.cpp"
- "**.h"
- "CMakeLists.txt"
- "**.cmake"

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand Down Expand Up @@ -40,4 +44,4 @@ jobs:
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Run app
run: ./build/Swirl
run: ./build/swirl
50 changes: 30 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,38 @@ jobs:
- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}}

- name: Package with CPack
run: |
cd build
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
cpack -G DEB
cpack -G RPM
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
cpack -G DragNDrop
elif [ "${{ matrix.os }}" == "windows-latest" ]; then
cpack -G NSIS
fi
cd ..
- name: rename and run the app
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
mv build/Swirl.exe build/swirl-windows.exe
mv build/swirl.exe build/swirl-windows.exe
./build/swirl-windows.exe
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
mv build/Swirl build/swirl-macos
mv build/swirl build/swirl-macos
./build/swirl-macos
else
mv build/Swirl build/swirl-linux
mv build/swirl build/swirl-linux
./build/swirl-linux
fi
- name: Upload binary
- name: Upload binaries and packages
uses: actions/upload-artifact@v2
with:
name: binary
path: build/Swirl-*
path: build/swirl-*

github-release:
name: GitHub Release
Expand All @@ -84,29 +98,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/download-artifact@v2
with:
name: binary
path: .

# Need to set an output variable because env variables can't be taken as input
# This is needed for the next step with releasing to GitHub
#- name: Find release type
# id: release_type
# env:
# IS_PRERELEASE: ${{ contains(github.event.inputs.version_number, 'alpha') || contains(github.event.inputs.version_number, 'beta') }}
# run: |
# echo "isPrerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT


- name: Generate release notes
run: npx git-cliff@latest --unreleased --tag ${{github.event.inputs.version_number}} --output CHANGELOG.md

- name: Creating GitHub Release
uses: softprops/action-gh-release@v1
with:
name: v${{github.event.inputs.version_number}}
tag_name: v${{github.event.inputs.version_number}}
#prerelease: ${{ steps.release_type.outputs.isPrerelease }}
target_commitish: ${{github.event.inputs.sha}}
generate_release_notes: true
body_path: CHANGELOG.md
files: |
swirl-linux
swirl-macos
swirl-windows.exe
swirl-*
49 changes: 21 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,20 @@ Thanks for contributing to Swirl. We want to make contributing to this project a
Pull requests are the best way to propose changes to the codebase. Do not make a pull request for adding a stuff which is incomplete or if you have not changed anything major in the source. If there are typos in identifiers or in strings, do NOT make PR's but create an issue to inform us instead. We actively welcome your pull requests:

## Process of submitting a pull request
1. Fork the repo. And [build](#building-the-project) the project
1. Fork the repo. And [build](https://swirl-lang.vercel.app/docs/getting-started/installation#command-line) the project
1. If you've added code that should be tested, add tests.
1. If you've changed APIs, update the documentation.
1. If you've changed APIs, inform us about the required documentation changes needed.
1. Ensure the tests passes.
1. Make sure your code is readable.
1. Issue that pull request!

## Building the project
The project uses CMake as the build tool. So make sure you have CMake installed on your system.<br>
After cloning the repo cd into it and follow the steps below.
### Configure CMake
```bash
cmake -B build -DCMAKE_BUILD_TYPE=Debug -S Swirl
```

### Build the project
```bash
cmake --build build --config Debug
```
### Run the app
```bash
./build/swirl
```
## Any contributions you make will be under the GPL v3.0 License

In short, when you submit code changes, your submissions are understood to be under the same [GPL v3.0 License](https://choosealicense.com/licenses/gpl-3.0/) that covers the project. Feel free to contact the maintainers if that's a concern.

## Report bugs using Github's [issues](https://github.com/SwirlLang/Swirl/issues)
## Report bugs using Github [issues](https://github.com/SwirlLang/Swirl/issues)

We use GitHub issues to track public bugs. Report a bug by choosing a issue template [here](https://github.com/SwirlLang/Swirl/issues/new/choose). it's that easy!
We use GitHub issues to track public bugs. Report a bug by choosing a issue template [here](https://github.com/SwirlLang/Swirl/issues/new/choose).

## Write bug reports with detail, background, and sample code

Expand Down Expand Up @@ -79,26 +63,35 @@ The following conventions are being used while authoring Swirl, we request contr

## Commit messages guideline

Here are the guidelines for writing effective commit messages:
We use [Conventional Commits](https://conventionalcommits.org) to make our commit messages more readable and to automate changelog generation. Please read the spec before committing to the project.

**Keep the subject line short and concise**: The subject line should be a brief summary of the changes made in the commit. It should be no more than 50 characters long, and it should not end with a period.
On top of the Conventional Commits, we have a few more guidelines to follow:

**Use the imperative mood in the subject line**: The subject line should describe what the commit does, rather than what has been done. For example, "Add feature X" is better than "Added feature X."

**Use the body to provide context and details**: The body of the commit message should provide more detailed information about the changes made in the commit. It should explain the motivations behind the changes, and it should provide any relevant context or background information.
**Use bullet points to list specific changes**: If the commit includes multiple changes, it can be helpful to use bullet points to list them out. This helps to make the commit message more organized and easier to read.

**Separate the subject line and body with a blank line**: Use a blank line to separate the subject line from the body of the commit message. This helps to visually distinguish between the two sections of the message.
**Use scopes to specify part of the codebase**: Conventional Commits allows you to specify a scope for your commit. This helps to make the commit message more organized and easier to read. The following are the scopes that we use:

**Use bullet points to list specific changes**: If the commit includes multiple changes, it can be helpful to use bullet points to list them out. This helps to make the commit message more organized and easier to read.
* **parser**: For changes made to the parser.
* **transpiler**: For changes made to the transpiler.
* **tokenizer**: For changes made to the transpiler.
* **pre-processor**: For changes made to the preprocessor.
* **cli**: For changes made to the cli.
* **cmake**: For changes made to the CMake files.

**Use tags to highlight important information**: The tags should be used to reflect the name of the file or component updated. Like cli, parser, transpiler.
If you can't find proper scope here, you can use the file name as the scope. For example, if you are updating the file `README.md`, you can use the scope `readme`.

If you are unsure about the scope to use, you can leave the field empty.

**Use proper spelling and grammar**: Make sure to use proper spelling and grammar in your commit messages. This helps to ensure that the messages are clear and easy to understand.

A example commit message:
```
CLI: Update include guard
docs(contributing): add conventional commits to contributing guidelines
Contributing guidelines has been updated to reflect the recent changes to use Conventional Commits as spec for the commits for the project.
Shifted include guard location after the include statements. And changed include guard format from SWIRL_CLI_H to CLI_H_Swirl.
Closes #42
```
That's all, Thank you for having a look!
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align=center>
<img width=500 src="https://raw.githubusercontent.com/SwirlLang/branding/main/logos/Swirl-wordmark-logo(transparent).png">
<img width=500 src="https://raw.githubusercontent.com/SwirlLang/branding/main/logos/wordmark-logo-transparent.png">

# Swirl programming language
A high level, statically typed, object-oriented programming language.
Expand Down
11 changes: 8 additions & 3 deletions Swirl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(Swirl VERSION 0.0.4)
project(swirl VERSION 0.0.5)
configure_file(include/SwirlConfig.h.in include/SwirlConfig.h)

# specify the C++ standard
Expand All @@ -14,7 +14,7 @@ option(BUILD_STDLIB "Build the standard library" OFF)
include_directories("include")
include_directories("${PROJECT_BINARY_DIR}")

add_executable(Swirl src/swirl.cpp)
add_executable(swirl src/swirl.cpp)
add_compile_options(-O3)

add_subdirectory(src)
Expand All @@ -23,4 +23,9 @@ if(BUILD_STDLIB)
endif()

install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION bin)
install(DIRECTORY include/ DESTINATION include)

if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(FILES "man/swirl.1" DESTINATION share/man/man1)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")

include(CPackConfig.cmake)
27 changes: 27 additions & 0 deletions Swirl/CPackConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# CPack config
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Swirl")
set(CPACK_PACKAGE_VENDOR "Swirl Lang")
set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Swirl compiler")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/resources/LICENSE")

# RPM config
set(CPACK_RPM_PACKAGE_DESCRIPTION "Swirl is a modern, general-purpose programming language designed to meet the evolving needs of today's developers. It is a high-level, statically typed, compiled, and object-oriented language that emphasizes both readability and performance.")
set(CPACK_RPM_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_RPM_PACKAGE_RELEASE "1")
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
set(CPACK_RPM_PACKAGE_GROUP "Development/Tools")
set(CPACK_RPM_PACKAGE_URL "https://swirl-lang.vercel.app")

# DEB config
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Swirl Lang")

# NSIS config
set(CPACK_NSIS_DISPLAY_NAME "Swirl")
set(CPACK_NSIS_CONTACT "Swirl Lang")
set(CPACK_NSIS_BRANDING_TEXT "Swirl Lang")
set(CPACK_NSIS_URL_INFO_ABOUT "https://swirl-lang.vercel.app")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_MENU_LINKS "https://swirl-lang.vercel.app" "Swirl website" "https://github.com/SwirlLang/Swirl" "Swirl GitHub repo")

include(CPack)
6 changes: 3 additions & 3 deletions Swirl/include/SwirlConfig.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Configured options for Swirl
#define Swirl_VERSION_MAJOR @Swirl_VERSION_MAJOR@
#define Swirl_VERSION_MINOR @Swirl_VERSION_MINOR@
#define Swirl_VERSION_PATCH @Swirl_VERSION_PATCH@
#define swirl_VERSION_MAJOR @swirl_VERSION_MAJOR@
#define swirl_VERSION_MINOR @swirl_VERSION_MINOR@
#define swirl_VERSION_PATCH @swirl_VERSION_PATCH@
27 changes: 14 additions & 13 deletions Swirl/include/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ struct Argument {
};

class cli {
private:
int m_argc;
const char ** m_argv;
public:
cli(int argc, const char** argv, const std::vector<Argument>& flags);

std::vector<Argument> m_flags, m_args;
public:
bool contains_flag(std::string_view flag);
std::string get_flag_value(std::string_view flag);
std::string generate_help();

std::optional<std::string> get_file();

private:
std::vector<Argument> parse(int argc, const char **argv, const std::vector<Argument>& flags);
std::vector<Argument> parse();

/**
* This function returns the value of the flag requested from the provided args vector.
Expand All @@ -45,15 +49,12 @@ class cli {
*/
std::variant<std::string, bool> get_flag(std::string_view flag);

public:
cli(int argc, const char** argv, const std::vector<Argument>& flags);

public:
bool contains_flag(std::string_view flag);
std::string get_flag_value(std::string_view flag);
std::string generate_help();
private:
int m_argc;
const char ** m_argv;

std::optional<std::string> get_file();
const std::vector<Argument> *m_flags;
std::vector<Argument> m_args;
};

#endif
28 changes: 28 additions & 0 deletions Swirl/man/swirl.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH SWIRL "1" "March 2023" "Swirl" "User Commands"
.SH NAME
Swirl \- manual page for Swirl
.SH SYNOPSIS
.B Swirl
\fI\,<input-file> \/\fR[\fI\,flags\/\fR]
.SH DESCRIPTION
The Swirl compiler
.SS "Flags:"
.TP
\fB\-h\fR, \fB\-\-help\fR
Shows this help message
.TP
\fB\-r\fR, \fB\-\-run\fR
Run the compiled file
.TP
\fB\-o\fR, \fB\-\-output\fR
Output file name
.TP
\fB\-c\fR, \fB\-\-compiler\fR
C++ compiler to use
.TP
\fB\-d\fR, \fB\-\-debug\fR
Log the steps of compilation
.TP
\fB\-v\fR, \fB\-\-version\fR
Shows the version of Swirl
Loading

0 comments on commit 7794d48

Please sign in to comment.