From 20a05e02be58f868f2dbaddebe2431583abaf8f1 Mon Sep 17 00:00:00 2001 From: Jon Ringle Date: Fri, 29 Sep 2023 18:44:56 -0400 Subject: [PATCH] Restructure c_src tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c_src/ ├── device/ │   ├── cairo/ │   │   ├── cairo_common.c │   │   ├── cairo_ctx.h │   │   ├── cairo_fb.c │   │   ├── cairo_fb.c.new │   │   ├── cairo_font_ops.c │   │   ├── cairo_gtk.c │   │   ├── cairo_image_ops.c │   │   └── cairo_script_ops.c │   ├── device.h │   └── nvg/ │   ├── bcm.c │   ├── drm.c │   ├── glfw.c │   ├── gl_helpers.c │   ├── nanovg/ │   │   ├── LICENSE.txt │   │   ├── nanovg.c │   │   ├── nanovg_gl.h │   │   ├── nanovg_gl_utils.h │   │   └── nanovg.h │   ├── nvg_font_ops.c │   ├── nvg_image_ops.c │   └── nvg_script_ops.c ├── font/ │   ├── font.c │   ├── font.h │   ├── font_ops.h │   ├── fontstash.h │   └── stb_truetype.h ├── image/ │   ├── image.c │   ├── image.h │   ├── image_ops.h │   └── stb_image.h ├── main.c ├── scenic/ │   ├── common.h │   ├── comms.c │   ├── comms.h │   ├── scenic_ops.c │   ├── scenic_ops.h │   ├── scenic_types.h │   ├── script.c │   ├── script.h │   ├── script_ops.c │   ├── script_ops.h │   ├── unix_comms.c │   ├── unix_comms.h │   ├── utils.c │   └── utils.h └── tommyds/ --- Makefile | 52 +++++++++---------- c_src/device/{ => cairo}/cairo_ctx.h | 2 +- c_src/device/{cairo.c => cairo/cairo_fb.c} | 1 - c_src/{font => device/cairo}/cairo_font_ops.c | 0 .../{image => device/cairo}/cairo_image_ops.c | 0 .../ops => device/cairo}/cairo_script_ops.c | 0 c_src/device/{ => nvg}/bcm.c | 4 +- c_src/device/{ => nvg}/drm.c | 4 +- c_src/device/{ => nvg}/gl_helpers.c | 0 c_src/device/{ => nvg}/glfw.c | 4 +- c_src/{ => device/nvg}/nanovg/LICENSE.txt | 36 ++++++------- c_src/{ => device/nvg}/nanovg/nanovg.c | 0 c_src/{ => device/nvg}/nanovg/nanovg.h | 0 c_src/{ => device/nvg}/nanovg/nanovg_gl.h | 0 .../{ => device/nvg}/nanovg/nanovg_gl_utils.h | 0 c_src/{font => device/nvg}/nvg_font_ops.c | 2 +- c_src/{image => device/nvg}/nvg_image_ops.c | 2 +- .../ops => device/nvg}/nvg_script_ops.c | 2 +- c_src/font/font.h | 1 - c_src/scenic/comms.c | 2 +- c_src/scenic/{ops => }/scenic_ops.c | 0 c_src/scenic/{ops => }/scenic_ops.h | 0 c_src/scenic/script.c | 2 +- c_src/scenic/{ops => }/script_ops.c | 0 c_src/scenic/{ops => }/script_ops.h | 0 25 files changed, 56 insertions(+), 58 deletions(-) rename c_src/device/{ => cairo}/cairo_ctx.h (97%) rename c_src/device/{cairo.c => cairo/cairo_fb.c} (99%) rename c_src/{font => device/cairo}/cairo_font_ops.c (100%) rename c_src/{image => device/cairo}/cairo_image_ops.c (100%) rename c_src/{scenic/ops => device/cairo}/cairo_script_ops.c (100%) rename c_src/device/{ => nvg}/bcm.c (99%) rename c_src/device/{ => nvg}/drm.c (99%) rename c_src/device/{ => nvg}/gl_helpers.c (100%) rename c_src/device/{ => nvg}/glfw.c (99%) rename c_src/{ => device/nvg}/nanovg/LICENSE.txt (97%) rename c_src/{ => device/nvg}/nanovg/nanovg.c (100%) rename c_src/{ => device/nvg}/nanovg/nanovg.h (100%) rename c_src/{ => device/nvg}/nanovg/nanovg_gl.h (100%) rename c_src/{ => device/nvg}/nanovg/nanovg_gl_utils.h (100%) rename c_src/{font => device/nvg}/nvg_font_ops.c (92%) rename c_src/{image => device/nvg}/nvg_image_ops.c (95%) rename c_src/{scenic/ops => device/nvg}/nvg_script_ops.c (99%) rename c_src/scenic/{ops => }/scenic_ops.c (100%) rename c_src/scenic/{ops => }/scenic_ops.h (100%) rename c_src/scenic/{ops => }/script_ops.c (100%) rename c_src/scenic/{ops => }/script_ops.h (100%) diff --git a/Makefile b/Makefile index 9043f5d..7b422c6 100644 --- a/Makefile +++ b/Makefile @@ -50,12 +50,24 @@ TOMMYDS_SRCS = \ SCENIC_SRCS = \ c_src/scenic/comms.c \ - c_src/scenic/ops/scenic_ops.c \ - c_src/scenic/ops/script_ops.c \ + c_src/scenic/scenic_ops.c \ + c_src/scenic/script_ops.c \ c_src/scenic/script.c \ c_src/scenic/unix_comms.c \ c_src/scenic/utils.c +NVG_COMMON_SRCS = \ + c_src/device/nvg/gl_helpers.c \ + c_src/device/nvg/nanovg/nanovg.c \ + c_src/device/nvg/nvg_font_ops.c \ + c_src/device/nvg/nvg_image_ops.c \ + c_src/device/nvg/nvg_script_ops.c + +CAIRO_COMMON_SRCS = \ + c_src/device/cairo/cairo_font_ops.c \ + c_src/device/cairo/cairo_image_ops.c \ + c_src/device/cairo/cairo_script_ops.c + ifeq ($(SCENIC_LOCAL_TARGET),glfw) CFLAGS = -O3 -std=c99 @@ -85,12 +97,8 @@ ifeq ($(SCENIC_LOCAL_TARGET),glfw) endif DEVICE_SRCS += \ - c_src/device/glfw.c \ - c_src/device/gl_helpers.c \ - c_src/nanovg/nanovg.c - FONT_SRCS += c_src/font/nvg_font_ops.c - IMAGE_SRCS += c_src/image/nvg_image_ops.c - SCENIC_SRCS += c_src/scenic/ops/nvg_script_ops.c + $(NVG_COMMON_SRCS) \ + c_src/device/nvg/glfw.c else ifeq ($(SCENIC_LOCAL_TARGET),bcm) LDFLAGS += -lGLESv2 -lEGL -lm -lvchostif -lbcm_host @@ -98,12 +106,8 @@ else ifeq ($(SCENIC_LOCAL_TARGET),bcm) CFLAGS += -std=gnu99 DEVICE_SRCS += \ - c_src/device/bcm.c \ - c_src/device/gl_helpers.c \ - c_src/nanovg/nanovg.c - FONT_SRCS += c_src/font/nvg_font_ops.c - IMAGE_SRCS += c_src/image/nvg_image_ops.c - SCENIC_SRCS += c_src/scenic/ops/nvg_script_ops.c + $(NVG_COMMON_SRCS) \ + c_src/device/nvg/bcm.c ifeq ($(SCENIC_LOCAL_GL),gles2) CFLAGS += -DSCENIC_GLES2 @@ -119,29 +123,26 @@ else ifeq ($(SCENIC_LOCAL_TARGET),drm) CFLAGS += -fPIC -I$(NERVES_SDK_SYSROOT)/usr/include/drm DEVICE_SRCS += \ - c_src/device/drm.c \ - c_src/device/gl_helpers.c \ - c_src/nanovg/nanovg.c - FONT_SRCS += c_src/font/nvg_font_ops.c - IMAGE_SRCS += c_src/image/nvg_image_ops.c - SCENIC_SRCS += c_src/scenic/ops/nvg_script_ops.c + $(NVG_COMMON_SRCS) \ + c_src/device/nvg/drm.c ifeq ($(SCENIC_LOCAL_GL),gles2) CFLAGS += -DSCENIC_GLES2 else CFLAGS += -DSCENIC_GLES3 endif -else ifeq ($(SCENIC_LOCAL_TARGET),cairo) + +else ifeq ($(SCENIC_LOCAL_TARGET),cairo-fb) LDFLAGS += `pkg-config --static --libs freetype2 cairo` CFLAGS += `pkg-config --static --cflags freetype2 cairo` LDFLAGS += -lm CFLAGS ?= -O2 -Wall -Wextra -Wno-unused-parameter -pedantic CFLAGS += -std=gnu99 - DEVICE_SRCS += c_src/device/cairo.c - FONT_SRCS += c_src/font/cairo_font_ops.c - IMAGE_SRCS += c_src/image/cairo_image_ops.c - SCENIC_SRCS += c_src/scenic/ops/cairo_script_ops.c + DEVICE_SRCS += \ + $(CAIRO_COMMON_SRCS) \ + c_src/device/cairo/cairo_fb.c + else $(info ------ no SCENIC_LOCAL_TARGET set ------) $(info If you get here, then you are probably using a custom Nerves system) @@ -173,7 +174,6 @@ CFLAGS += \ -Ic_src/device \ -Ic_src/font \ -Ic_src/image \ - -Ic_src/nanovg \ -Ic_src/scenic \ -Ic_src/tommyds/src diff --git a/c_src/device/cairo_ctx.h b/c_src/device/cairo/cairo_ctx.h similarity index 97% rename from c_src/device/cairo_ctx.h rename to c_src/device/cairo/cairo_ctx.h index 086db76..3f67075 100644 --- a/c_src/device/cairo_ctx.h +++ b/c_src/device/cairo/cairo_ctx.h @@ -3,7 +3,7 @@ #include #include #include FT_FREETYPE_H -#include "ops/script_ops.h" +#include "script_ops.h" typedef struct { cairo_pattern_t* fill; diff --git a/c_src/device/cairo.c b/c_src/device/cairo/cairo_fb.c similarity index 99% rename from c_src/device/cairo.c rename to c_src/device/cairo/cairo_fb.c index 5bf71db..0a9df24 100644 --- a/c_src/device/cairo.c +++ b/c_src/device/cairo/cairo_fb.c @@ -12,7 +12,6 @@ #include "comms.h" #include "device.h" #include "fontstash.h" -#include "ops/script_ops.h" const char* device = "/dev/fb0"; diff --git a/c_src/font/cairo_font_ops.c b/c_src/device/cairo/cairo_font_ops.c similarity index 100% rename from c_src/font/cairo_font_ops.c rename to c_src/device/cairo/cairo_font_ops.c diff --git a/c_src/image/cairo_image_ops.c b/c_src/device/cairo/cairo_image_ops.c similarity index 100% rename from c_src/image/cairo_image_ops.c rename to c_src/device/cairo/cairo_image_ops.c diff --git a/c_src/scenic/ops/cairo_script_ops.c b/c_src/device/cairo/cairo_script_ops.c similarity index 100% rename from c_src/scenic/ops/cairo_script_ops.c rename to c_src/device/cairo/cairo_script_ops.c diff --git a/c_src/device/bcm.c b/c_src/device/nvg/bcm.c similarity index 99% rename from c_src/device/bcm.c rename to c_src/device/nvg/bcm.c index 0e5f04c..68a83be 100644 --- a/c_src/device/bcm.c +++ b/c_src/device/nvg/bcm.c @@ -21,8 +21,8 @@ #include #define NANOVG_GLES2_IMPLEMENTATION -#include "nanovg.h" -#include "nanovg_gl.h" +#include "nanovg/nanovg.h" +#include "nanovg/nanovg_gl.h" #include "scenic_types.h" #include "comms.h" diff --git a/c_src/device/drm.c b/c_src/device/nvg/drm.c similarity index 99% rename from c_src/device/drm.c rename to c_src/device/nvg/drm.c index 439e9d4..fc7d464 100644 --- a/c_src/device/drm.c +++ b/c_src/device/nvg/drm.c @@ -24,8 +24,8 @@ #define NANOVG_GLES3_IMPLEMENTATION #endif #include -#include "nanovg.h" -#include "nanovg_gl.h" +#include "nanovg/nanovg.h" +#include "nanovg/nanovg_gl.h" #include "scenic_types.h" #include "comms.h" diff --git a/c_src/device/gl_helpers.c b/c_src/device/nvg/gl_helpers.c similarity index 100% rename from c_src/device/gl_helpers.c rename to c_src/device/nvg/gl_helpers.c diff --git a/c_src/device/glfw.c b/c_src/device/nvg/glfw.c similarity index 99% rename from c_src/device/glfw.c rename to c_src/device/nvg/glfw.c index 67d2c1c..6c24955 100644 --- a/c_src/device/glfw.c +++ b/c_src/device/nvg/glfw.c @@ -18,8 +18,8 @@ #include #define NANOVG_GL2_IMPLEMENTATION -#include "nanovg.h" -#include "nanovg_gl.h" +#include "nanovg/nanovg.h" +#include "nanovg/nanovg_gl.h" #include "scenic_types.h" #include "utils.h" diff --git a/c_src/nanovg/LICENSE.txt b/c_src/device/nvg/nanovg/LICENSE.txt similarity index 97% rename from c_src/nanovg/LICENSE.txt rename to c_src/device/nvg/nanovg/LICENSE.txt index 2a03a1a..c9a1534 100644 --- a/c_src/nanovg/LICENSE.txt +++ b/c_src/device/nvg/nanovg/LICENSE.txt @@ -1,18 +1,18 @@ -Copyright (c) 2013 Mikko Mononen memon@inside.org - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not -claim that you wrote the original software. If you use this software -in a product, an acknowledgment in the product documentation would be -appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be -misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. - +Copyright (c) 2013 Mikko Mononen memon@inside.org + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + diff --git a/c_src/nanovg/nanovg.c b/c_src/device/nvg/nanovg/nanovg.c similarity index 100% rename from c_src/nanovg/nanovg.c rename to c_src/device/nvg/nanovg/nanovg.c diff --git a/c_src/nanovg/nanovg.h b/c_src/device/nvg/nanovg/nanovg.h similarity index 100% rename from c_src/nanovg/nanovg.h rename to c_src/device/nvg/nanovg/nanovg.h diff --git a/c_src/nanovg/nanovg_gl.h b/c_src/device/nvg/nanovg/nanovg_gl.h similarity index 100% rename from c_src/nanovg/nanovg_gl.h rename to c_src/device/nvg/nanovg/nanovg_gl.h diff --git a/c_src/nanovg/nanovg_gl_utils.h b/c_src/device/nvg/nanovg/nanovg_gl_utils.h similarity index 100% rename from c_src/nanovg/nanovg_gl_utils.h rename to c_src/device/nvg/nanovg/nanovg_gl_utils.h diff --git a/c_src/font/nvg_font_ops.c b/c_src/device/nvg/nvg_font_ops.c similarity index 92% rename from c_src/font/nvg_font_ops.c rename to c_src/device/nvg/nvg_font_ops.c index e7a6612..5aea48f 100644 --- a/c_src/font/nvg_font_ops.c +++ b/c_src/device/nvg/nvg_font_ops.c @@ -1,5 +1,5 @@ #include "font_ops.h" -#include "nanovg.h" +#include "nanovg/nanovg.h" int32_t font_ops_create(void* v_ctx, font_t* p_font, uint32_t size) { diff --git a/c_src/image/nvg_image_ops.c b/c_src/device/nvg/nvg_image_ops.c similarity index 95% rename from c_src/image/nvg_image_ops.c rename to c_src/device/nvg/nvg_image_ops.c index d28c22a..80a062f 100644 --- a/c_src/image/nvg_image_ops.c +++ b/c_src/device/nvg/nvg_image_ops.c @@ -1,6 +1,6 @@ #include "comms.h" #include "image_ops.h" -#include "nanovg.h" +#include "nanovg/nanovg.h" #define REPEAT_XY (NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY) diff --git a/c_src/scenic/ops/nvg_script_ops.c b/c_src/device/nvg/nvg_script_ops.c similarity index 99% rename from c_src/scenic/ops/nvg_script_ops.c rename to c_src/device/nvg/nvg_script_ops.c index 8a739a0..1f2ceec 100644 --- a/c_src/scenic/ops/nvg_script_ops.c +++ b/c_src/device/nvg/nvg_script_ops.c @@ -5,7 +5,7 @@ #include "image.h" #include "script_ops.h" #include "scenic_types.h" -#include "nanovg.h" +#include "nanovg/nanovg.h" extern device_opts_t g_opts; diff --git a/c_src/font/font.h b/c_src/font/font.h index 8b0992b..19874a0 100644 --- a/c_src/font/font.h +++ b/c_src/font/font.h @@ -7,7 +7,6 @@ #pragma once #include "scenic_types.h" -#include "nanovg.h" #include "font_ops.h" void init_fonts(void); diff --git a/c_src/scenic/comms.c b/c_src/scenic/comms.c index ca98cff..6f70f15 100644 --- a/c_src/scenic/comms.c +++ b/c_src/scenic/comms.c @@ -17,7 +17,7 @@ The caller will typically be erlang, so use the 2-byte length indicator #include "device.h" #include "font.h" #include "image.h" -#include "ops/scenic_ops.h" +#include "scenic_ops.h" #include "script.h" #include "utils.h" diff --git a/c_src/scenic/ops/scenic_ops.c b/c_src/scenic/scenic_ops.c similarity index 100% rename from c_src/scenic/ops/scenic_ops.c rename to c_src/scenic/scenic_ops.c diff --git a/c_src/scenic/ops/scenic_ops.h b/c_src/scenic/scenic_ops.h similarity index 100% rename from c_src/scenic/ops/scenic_ops.h rename to c_src/scenic/scenic_ops.h diff --git a/c_src/scenic/script.c b/c_src/scenic/script.c index b5e2189..9538d04 100644 --- a/c_src/scenic/script.c +++ b/c_src/scenic/script.c @@ -10,7 +10,7 @@ #include "comms.h" #include "font.h" #include "image.h" -#include "ops/script_ops.h" +#include "script_ops.h" #include "script.h" #include "utils.h" diff --git a/c_src/scenic/ops/script_ops.c b/c_src/scenic/script_ops.c similarity index 100% rename from c_src/scenic/ops/script_ops.c rename to c_src/scenic/script_ops.c diff --git a/c_src/scenic/ops/script_ops.h b/c_src/scenic/script_ops.h similarity index 100% rename from c_src/scenic/ops/script_ops.h rename to c_src/scenic/script_ops.h