mirror of https://github.com/aseprite/aseprite.git
Merge branch 'main' into beta
This commit is contained in:
commit
b2e8cfc88f
|
@ -69,6 +69,7 @@ option(USE_SHARED_CURL "Use your installed copy of curl" off)
|
||||||
option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off)
|
option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off)
|
||||||
option(USE_SHARED_ZLIB "Use your installed copy of zlib" off)
|
option(USE_SHARED_ZLIB "Use your installed copy of zlib" off)
|
||||||
option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off)
|
option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off)
|
||||||
|
option(USE_SHARED_TINYEXIF "Use your installed copy of TinyEXIF" off)
|
||||||
option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
|
option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
|
||||||
option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
|
option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
|
||||||
option(USE_SHARED_FREETYPE "Use shared FreeType library" off)
|
option(USE_SHARED_FREETYPE "Use shared FreeType library" off)
|
||||||
|
@ -190,6 +191,7 @@ set(PIXMAN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/pixman)
|
||||||
set(FREETYPE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/freetype2)
|
set(FREETYPE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/freetype2)
|
||||||
set(HARFBUZZ_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/harfbuzz)
|
set(HARFBUZZ_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/harfbuzz)
|
||||||
set(SIMPLEINI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/simpleini)
|
set(SIMPLEINI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/simpleini)
|
||||||
|
set(TINYEXIF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/TinyEXIF)
|
||||||
set(TINYXML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tinyxml2)
|
set(TINYXML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tinyxml2)
|
||||||
set(ZLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
|
set(ZLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
|
||||||
|
|
||||||
|
@ -262,6 +264,16 @@ else()
|
||||||
endif()
|
endif()
|
||||||
include_directories(${TINYXML_INCLUDE_DIR})
|
include_directories(${TINYXML_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# TinyEXIF
|
||||||
|
if(USE_SHARED_TINYEXIF)
|
||||||
|
find_library(TINYEXIF_LIBRARY NAMES TinyEXIF)
|
||||||
|
find_path(TINYEXIF_INCLUDE_DIR NAMES TinyEXIF.h)
|
||||||
|
else()
|
||||||
|
set(TINYEXIF_LIBRARY TinyEXIFstatic)
|
||||||
|
set(TINYEXIF_INCLUDE_DIR ${TINYEXIF_DIR})
|
||||||
|
endif()
|
||||||
|
include_directories(${TINYEXIF_INCLUDE_DIR})
|
||||||
|
|
||||||
# pixman
|
# pixman
|
||||||
if(USE_SHARED_PIXMAN)
|
if(USE_SHARED_PIXMAN)
|
||||||
find_library(PIXMAN_LIBRARY NAMES pixman pixman-1)
|
find_library(PIXMAN_LIBRARY NAMES pixman pixman-1)
|
||||||
|
|
|
@ -2,39 +2,48 @@
|
||||||
|
|
||||||
Some general rules to write code: Try to follow the same style/format
|
Some general rules to write code: Try to follow the same style/format
|
||||||
of the file that you are editing (naming, indentation, etc.) or the
|
of the file that you are editing (naming, indentation, etc.) or the
|
||||||
style of the module (some [submodules](https://github.com/aseprite/aseprite/blob/main/.gitmodules),
|
style of the module. Some [submodules](https://github.com/aseprite/aseprite/blob/main/.gitmodules),
|
||||||
created by us, or by third-parties, have their own style).
|
created by us, or by third-parties, have their own style.
|
||||||
|
|
||||||
|
## clang-format
|
||||||
|
|
||||||
There is a [.clang-format](https://github.com/aseprite/aseprite/blob/main/.clang-format)
|
There is a [.clang-format](https://github.com/aseprite/aseprite/blob/main/.clang-format)
|
||||||
file available but we are not using it at the moment, probably we
|
file available for Aseprite and laf, and we are using it with
|
||||||
should start using some
|
Clang 19. You have to configure a [pre-commit](../CONTRIBUTING.md#pre-commit-hooks)
|
||||||
[clang-format-diff.py](https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting)
|
hook which will help you to do the formatting automatically before committing.
|
||||||
for patches, but this wasn't yet adopted in the development process.
|
|
||||||
|
|
||||||
There is a [.clang-tidy](https://github.com/aseprite/aseprite/blob/main/.clang-tidy)
|
There is a [.clang-tidy](https://github.com/aseprite/aseprite/blob/main/.clang-tidy)
|
||||||
file used [in the GitHub actions](https://github.com/aseprite/aseprite/blob/main/.github/workflows/clang_tidy.yml)
|
file used [in the GitHub actions](https://github.com/aseprite/aseprite/blob/main/.github/workflows/clang_tidy.yml)
|
||||||
executed on each PR. These rules are adopted progressively on patches
|
executed on each PR. These rules are adopted progressively on patches
|
||||||
because are only executed in the diff, and if some rule is violated a
|
because are only executed in the diff, and if some rule is violated a
|
||||||
comment by [aseprite-bot](https://github.com/aseprite-bot) is made.
|
comment by [aseprite-bot](https://github.com/aseprite-bot) is
|
||||||
|
made. (Sometimes the bot will be wrong, so be careful.)
|
||||||
|
|
||||||
|
## Column limit
|
||||||
|
|
||||||
|
We use a [column limit](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#columnlimit)
|
||||||
|
of 100. clang-format will break lines to avoid excessing more than 100
|
||||||
|
lines, but in some extreme cases it might not break this limit, as
|
||||||
|
our [PenaltyExcessCharacter](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#penaltyexcesscharacter)
|
||||||
|
is not the highest value.
|
||||||
|
|
||||||
## Basics
|
## Basics
|
||||||
|
|
||||||
Basic statements:
|
Basic statements:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
void global_function(int arg1,
|
void function_with_long_args(const int argument1,
|
||||||
const int arg2, // You can use "const" preferably
|
const int argument2,
|
||||||
const int arg3, ...)
|
const std::string& argument3,
|
||||||
|
const double argument4,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
int value;
|
}
|
||||||
const int constValue = 0;
|
|
||||||
|
|
||||||
// We prefer to use "var = (condition ? ...: ...)" instead of
|
void function_with_short_args(int arg1, const int arg2, const int arg3, ...)
|
||||||
// "var = condition ? ...: ...;" to make clear about the
|
{
|
||||||
// ternary operator limits.
|
const int constValue = 0;
|
||||||
int conditionalValue1 = (condition ? 1: 2);
|
int value;
|
||||||
int conditionalValue2 = (condition ? longVarName:
|
|
||||||
otherLongVarName);
|
|
||||||
|
|
||||||
// If a condition will return, we prefer the "return"
|
// If a condition will return, we prefer the "return"
|
||||||
// statement in its own line to avoid missing the "return"
|
// statement in its own line to avoid missing the "return"
|
||||||
|
@ -44,25 +53,20 @@ void global_function(int arg1,
|
||||||
|
|
||||||
// You can use braces {} if the condition has multiple lines
|
// You can use braces {} if the condition has multiple lines
|
||||||
// or the if-body has multiple lines.
|
// or the if-body has multiple lines.
|
||||||
if (condition1 ||
|
if (condition1 || condition2) {
|
||||||
condition2) {
|
...
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (condition) {
|
if (condition) {
|
||||||
...
|
...
|
||||||
...
|
|
||||||
...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We prefer to avoid whitespaces between "var=initial_value"
|
|
||||||
// or "var<limit" to see better the "; " separation. Anyway it
|
|
||||||
// can depend on the specific condition/case, etc.
|
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
...
|
|
||||||
// Same case as in if-return.
|
// Same case as in if-return.
|
||||||
if (condition)
|
if (condition)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,16 +79,13 @@ void global_function(int arg1,
|
||||||
} while (condition);
|
} while (condition);
|
||||||
|
|
||||||
switch (condition) {
|
switch (condition) {
|
||||||
case 1:
|
case 1: ... break;
|
||||||
...
|
|
||||||
break;
|
|
||||||
case 2: {
|
case 2: {
|
||||||
int varInsideCase;
|
int varInsideCase;
|
||||||
...
|
// ...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -108,11 +109,15 @@ Define classes with `CapitalCase` and member functions with `camelCase`:
|
||||||
```c++
|
```c++
|
||||||
class ClassName {
|
class ClassName {
|
||||||
public:
|
public:
|
||||||
ClassName()
|
ClassName() : m_memberVarA(1), m_memberVarB(2), m_memberVarC(3) {}
|
||||||
: m_memberVarA(1),
|
|
||||||
m_memberVarB(2),
|
ClassName(int a, int b, int c, int d)
|
||||||
m_memberVarC(3) {
|
: m_memberVarA(a)
|
||||||
...
|
, m_memberVarB(b)
|
||||||
|
, m_memberVarC(c)
|
||||||
|
, m_memberVarD(d)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ClassName();
|
virtual ~ClassName();
|
||||||
|
@ -137,7 +142,9 @@ public:
|
||||||
Special();
|
Special();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onEvent2() override { // No need to repeat virtual in overridden methods
|
void onEvent2() override
|
||||||
|
{
|
||||||
|
// No need to repeat virtual in overridden methods
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -150,7 +157,9 @@ We use the const-west notation:
|
||||||
* [NL.26: Use conventional const notation](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nl26-use-conventional-const-notation)
|
* [NL.26: Use conventional const notation](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nl26-use-conventional-const-notation)
|
||||||
|
|
||||||
There is a problem with `clang-tidy` that will make comments using
|
There is a problem with `clang-tidy` that will make comments using
|
||||||
East const notation: [#4361](https://github.com/aseprite/aseprite/issues/4361)
|
East const notation:
|
||||||
|
[#4361](https://github.com/aseprite/aseprite/issues/4361), but
|
||||||
|
clang-format should fix the `const` position anyway.
|
||||||
|
|
||||||
## C++17
|
## C++17
|
||||||
|
|
||||||
|
|
2
laf
2
laf
|
@ -1 +1 @@
|
||||||
Subproject commit 20d13cf0c762189650c7860bd3302a0a66cfa346
|
Subproject commit 2647cc0a948176aa85ae3f75f425a4a2554ac15e
|
|
@ -761,6 +761,7 @@ target_link_libraries(app-lib
|
||||||
undo
|
undo
|
||||||
${CMARK_LIBRARIES}
|
${CMARK_LIBRARIES}
|
||||||
${TINYXML_LIBRARY}
|
${TINYXML_LIBRARY}
|
||||||
|
${TINYEXIF_LIBRARY}
|
||||||
${GIF_LIBRARIES}
|
${GIF_LIBRARIES}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
|
@ -769,7 +770,6 @@ target_link_libraries(app-lib
|
||||||
archive_static
|
archive_static
|
||||||
fmt
|
fmt
|
||||||
tinyexpr
|
tinyexpr
|
||||||
TinyEXIFstatic
|
|
||||||
qoi)
|
qoi)
|
||||||
|
|
||||||
if(ENABLE_WEBP AND WEBP_FOUND)
|
if(ENABLE_WEBP AND WEBP_FOUND)
|
||||||
|
|
|
@ -54,11 +54,13 @@ if(NOT USE_SHARED_TINYXML)
|
||||||
add_subdirectory(tinyxml2)
|
add_subdirectory(tinyxml2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT USE_SHARED_TINYEXIF)
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build as shared library")
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build as shared library")
|
||||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "build as static library")
|
set(BUILD_STATIC_LIBS ON CACHE BOOL "build as static library")
|
||||||
set(LINK_CRT_STATIC_LIBS OFF CACHE BOOL "link CRT static library")
|
set(LINK_CRT_STATIC_LIBS OFF CACHE BOOL "link CRT static library")
|
||||||
set(BUILD_DEMO OFF CACHE BOOL "build demo binary")
|
set(BUILD_DEMO OFF CACHE BOOL "build demo binary")
|
||||||
add_subdirectory(TinyEXIF)
|
add_subdirectory(TinyEXIF)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(REQUIRE_CURL AND NOT USE_SHARED_CURL)
|
if(REQUIRE_CURL AND NOT USE_SHARED_CURL)
|
||||||
set(BUILD_RELEASE_DEBUG_DIRS ON BOOL)
|
set(BUILD_RELEASE_DEBUG_DIRS ON BOOL)
|
||||||
|
|
Loading…
Reference in New Issue