Merge branch 'main' into beta

This commit is contained in:
David Capello 2024-12-26 16:13:08 -03:00
commit b2e8cfc88f
5 changed files with 72 additions and 49 deletions

View File

@ -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_ZLIB "Use your installed copy of zlib" 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_PIXMAN "Use your installed copy of pixman" 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(HARFBUZZ_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/harfbuzz)
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(ZLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
@ -262,6 +264,16 @@ else()
endif()
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
if(USE_SHARED_PIXMAN)
find_library(PIXMAN_LIBRARY NAMES pixman pixman-1)

View File

@ -2,39 +2,48 @@
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
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).
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.
## 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
should start using some
[clang-format-diff.py](https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting)
for patches, but this wasn't yet adopted in the development process.
file available for Aseprite and laf, and we are using it with
Clang 19. You have to configure a [pre-commit](../CONTRIBUTING.md#pre-commit-hooks)
hook which will help you to do the formatting automatically before committing.
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)
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
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
Basic statements:
```c++
void global_function(int arg1,
const int arg2, // You can use "const" preferably
const int arg3, ...)
void function_with_long_args(const int argument1,
const int argument2,
const std::string& argument3,
const double argument4,
...)
{
int value;
const int constValue = 0;
}
// We prefer to use "var = (condition ? ...: ...)" instead of
// "var = condition ? ...: ...;" to make clear about the
// ternary operator limits.
int conditionalValue1 = (condition ? 1: 2);
int conditionalValue2 = (condition ? longVarName:
otherLongVarName);
void function_with_short_args(int arg1, const int arg2, const int arg3, ...)
{
const int constValue = 0;
int value;
// If a condition will return, we prefer 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
// or the if-body has multiple lines.
if (condition1 ||
condition2) {
if (condition1 || condition2) {
...
return;
}
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) {
...
// Same case as in if-return.
if (condition)
break;
...
}
@ -75,16 +79,13 @@ void global_function(int arg1,
} while (condition);
switch (condition) {
case 1:
...
break;
case 1: ... break;
case 2: {
int varInsideCase;
...
// ...
break;
}
default:
break;
default: break;
}
}
```
@ -108,11 +109,15 @@ Define classes with `CapitalCase` and member functions with `camelCase`:
```c++
class ClassName {
public:
ClassName()
: m_memberVarA(1),
m_memberVarB(2),
m_memberVarC(3) {
...
ClassName() : m_memberVarA(1), m_memberVarB(2), m_memberVarC(3) {}
ClassName(int a, int b, int c, int d)
: m_memberVarA(a)
, m_memberVarB(b)
, m_memberVarC(c)
, m_memberVarD(d)
{
// ...
}
virtual ~ClassName();
@ -137,7 +142,9 @@ public:
Special();
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)
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

2
laf

@ -1 +1 @@
Subproject commit 20d13cf0c762189650c7860bd3302a0a66cfa346
Subproject commit 2647cc0a948176aa85ae3f75f425a4a2554ac15e

View File

@ -761,6 +761,7 @@ target_link_libraries(app-lib
undo
${CMARK_LIBRARIES}
${TINYXML_LIBRARY}
${TINYEXIF_LIBRARY}
${GIF_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
@ -769,7 +770,6 @@ target_link_libraries(app-lib
archive_static
fmt
tinyexpr
TinyEXIFstatic
qoi)
if(ENABLE_WEBP AND WEBP_FOUND)

View File

@ -54,11 +54,13 @@ if(NOT USE_SHARED_TINYXML)
add_subdirectory(tinyxml2)
endif()
if(NOT USE_SHARED_TINYEXIF)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "build as shared 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(BUILD_DEMO OFF CACHE BOOL "build demo binary")
add_subdirectory(TinyEXIF)
endif()
if(REQUIRE_CURL AND NOT USE_SHARED_CURL)
set(BUILD_RELEASE_DEBUG_DIRS ON BOOL)