Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add a CI pass for pathfinder_c on Linux #379

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ language: rust
rust:
- nightly
- stable
cache: cargo
addons:
apt:
packages:
- libegl1-mesa-dev
- libgtk-3-dev
- libsdl2-dev
- libglfw3-dev
- cmake
script:
- cargo install sccache
- export RUSTC_WRAPPER=sccache
- rustup target add aarch64-unknown-linux-gnu
- cd simd
- cargo build --target aarch64-unknown-linux-gnu
Expand All @@ -18,6 +22,10 @@ script:
- cd ..
- cargo build
- cargo test
- cd c
- cargo cinstall --prefix=$TRAVIS_HOME/.fake-install
- cd ../examples/c_canvas_glfw_minimal
- PKG_CONFIG_PATH=$TRAVIS_HOME/.fake-install/lib/pkgconfig make
env:
global:
- HARFBUZZ_SYS_NO_PKG_CONFIG=true
Expand Down
10 changes: 7 additions & 3 deletions c/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ header = """\

#if defined(__APPLE__) && defined(__OBJC__)
#include <QuartzCore/QuartzCore.h>
typedef NSObject<CAMetalDrawable> NSObjectCAMetalDrawable;
typedef NSObject<MTLDevice> NSObjectMTLDevice;
#else
typedef struct CAMetalLayerPrivate CAMetalLayer;
typedef void* NSObjectCAMetalDrawable;
typedef void* NSObjectMTLDevice;
typedef void* IOSurfaceRef;
#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -42,14 +46,14 @@ include = [
"BuildOptions" = "PFBuildOptionsPrivate"
"CanvasFontContext" = "PFCanvasFontContextPrivate"
"CanvasRenderingContext2D" = "PFCanvasRenderingContext2DPrivate"
"CoreAnimationDrawableRef" = "NSObject<CAMetalDrawable>"
"CoreAnimationDrawableRef" = "NSObjectCAMetalDrawable"
"DestFramebuffer_GLDevice" = "PFDestFramebufferGLDevicePrivate"
"DestFramebuffer_MetalDevice" = "PFDestFramebufferMetalDevicePrivate"
"FillStyle" = "PFFillStylePrivate"
"GLDevice" = "PFGLDevicePrivate"
"Handle" = "FKHandlePrivate"
"MetalDevice" = "PFMetalDevicePrivate"
"NativeMetalDeviceRef" = "NSObject<MTLDevice>"
"NativeMetalDeviceRef" = "NSObjectMTLDevice"
"Path2D" = "PFPath2DPrivate"
"RenderTransform" = "PFRenderTransformPrivate"
"Renderer_GLDevice" = "PFRendererGLDevicePrivate"
Expand Down
2 changes: 1 addition & 1 deletion canvas/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// For this file only, any copyright is dedicated to the Public Domain.
// https://creativecommons.org/publicdomain/zero/1.0/

use pathfinder_geometry::vector::{Vector2F, vec2f};
use pathfinder_geometry::vector::vec2f;
use super::Path2D;

#[test]
Expand Down
5 changes: 3 additions & 2 deletions demo/native/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ use pathfinder_resources::ResourceLoader;
use pathfinder_resources::fs::FilesystemResourceLoader;
use std::cell::Cell;
use std::collections::VecDeque;
use std::mem;
use std::path::PathBuf;
use std::sync::Mutex;
use surfman::{SurfaceAccess, SurfaceType, declare_surfman};
use winit::{ControlFlow, ElementState, Event as WinitEvent, EventsLoop, EventsLoopProxy};
use winit::{MouseButton, VirtualKeyCode, Window as WinitWindow, WindowBuilder, WindowEvent};
use winit::dpi::LogicalSize;

#[cfg(all(target_os = "macos", not(feature = "pf-gl")))]
use std::mem;
#[cfg(any(not(target_os = "macos"), feature = "pf-gl"))]
use gl::types::GLuint;
#[cfg(any(not(target_os = "macos"), feature = "pf-gl"))]
Expand Down Expand Up @@ -494,4 +495,4 @@ fn convert_winit_event(winit_event: WinitEvent,
}
_ => None,
}
}
}
15 changes: 4 additions & 11 deletions examples/c_canvas_glfw_minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RUST_TARGET_DIR?=../../target
RUST_SRC_DIR?=../../c
RUSTFLAGS?=

CFLAGS?=-Wall -g -I../../c/build/include
LIBS?=-lpathfinder_c -lglfw
CFLAGS?=-Wall -g $(shell pkg-config --cflags pathfinder_c glfw3)
LIBS?=$(shell pkg-config --libs pathfinder_c glfw3)
MKDIR?=mkdir -p
RM?=rm
CARGO?=cargo
Expand All @@ -22,26 +22,19 @@ endif

ifeq ($(DEBUG),)
CFLAGS+=-O2
LDFLAGS?=-L$(RUST_TARGET_DIR)/release
CARGOFLAGS?=--release
else
CFLAGS+=-O0
LDFLAGS?=-L$(RUST_TARGET_DIR)/debug
CARGOFLAGS?=
endif

all: $(TARGET_DIR)/c_canvas_glfw_minimal

.PHONY: clean rustlib
.PHONY: clean

$(TARGET_DIR)/c_canvas_glfw_minimal: $(OBJ_DIR)/c_canvas_glfw_minimal.o rustlib
$(TARGET_DIR)/c_canvas_glfw_minimal: $(OBJ_DIR)/c_canvas_glfw_minimal.o
$(MKDIR) $(TARGET_DIR) && $(CC) $(LDFLAGS) $(LIBS) -o $@ $<

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(MKDIR) $(OBJ_DIR) && $(CC) -c $(CFLAGS) -o $@ $<

rustlib:
cd $(RUST_SRC_DIR) && RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build $(CARGOFLAGS)

clean:
$(RM) -rf $(TARGET_DIR) && $(RM) -rf $(OBJ_DIR)
15 changes: 11 additions & 4 deletions examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
// except according to those terms.

#include <GLFW/glfw3.h>
#include <pathfinder/pathfinder.h>
#include <pathfinder_c.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#ifndef GLFW_TRUE
#define GLFW_TRUE 1
#endif

static void HandleGLFWError(int errorCode, const char *description);
static const void *LoadGLFunction(const char *name, void *userdata);
static void HandleKeypress(GLFWwindow *window, int key, int scancode, int action, int mods);
Expand Down Expand Up @@ -44,9 +48,11 @@ int main(int argc, const char **argv) {
PFGLDestFramebufferCreateFullWindow(&(PFVector2I){640, 480});
PFGLRendererRef renderer = PFGLRendererCreate(PFGLDeviceCreate(PF_GL_VERSION_GL3, 0),
PFFilesystemResourceLoaderLocate(),
dest_framebuffer,
&(PFRendererMode){PF_RENDERER_LEVEL_D3D9},
&(PFRendererOptions){
(PFColorF){1.0, 1.0, 1.0, 1.0}, PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR
dest_framebuffer,
(PFColorF){1.0, 1.0, 1.0, 1.0},
PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR
});

// Make a canvas. We're going to draw a house.
Expand All @@ -72,7 +78,8 @@ int main(int argc, const char **argv) {

// Render the canvas to screen.
PFSceneRef scene = PFCanvasCreateScene(canvas);
PFSceneProxyRef scene_proxy = PFSceneProxyCreateFromSceneAndRayonExecutor(scene);
PFSceneProxyRef scene_proxy =
PFSceneProxyCreateFromSceneAndRayonExecutor(scene, PF_RENDERER_LEVEL_D3D9);
PFSceneProxyBuildAndRenderGL(scene_proxy, renderer, PFBuildOptionsCreate());
glfwSwapBuffers(window);

Expand Down
8 changes: 4 additions & 4 deletions examples/c_canvas_minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RUST_TARGET_DIR?=../../target
RUST_SRC_DIR?=../../c
RUSTFLAGS?=-C target-cpu=native

CFLAGS?=-Wall -g -I../../c/build/include
LIBS?=-lpathfinder_c
CFLAGS?=-Wall -g $(shell pkg-config --cflags pathfinder_c sdl2)
LIBS?=$(shell pkg-config --libs pathfinder_c sdl2)
MKDIR?=mkdir -p
RM?=rm
CARGO?=cargo
Expand Down Expand Up @@ -35,10 +35,10 @@ all: $(TARGET_DIR)/c_canvas_minimal
.PHONY: clean rustlib

$(TARGET_DIR)/c_canvas_minimal: $(OBJ_DIR)/c_canvas_minimal.o rustlib
$(MKDIR) $(TARGET_DIR) && $(CC) $(LDFLAGS) $(LIBS) `sdl2-config --libs` -o $@ $<
$(MKDIR) $(TARGET_DIR) && $(CC) $(LDFLAGS) $(LIBS) -o $@ $<

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(MKDIR) $(OBJ_DIR) && $(CC) -c $(CFLAGS) `sdl2-config --cflags` -o $@ $<
$(MKDIR) $(OBJ_DIR) && $(CC) -c $(CFLAGS) -o $@ $<

rustlib:
cd $(RUST_SRC_DIR) && RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build $(CARGOFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion examples/c_canvas_minimal/c_canvas_minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <pathfinder/pathfinder.h>
#include <pathfinder_c.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/concurrent/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
pub trait Executor {
/// Like the Rayon snippet:
///
/// ```norun
/// ```no_run
/// (0..length).into_par_iter().map(builder).collect()
/// ```
fn build_vector<T, F>(&self, length: usize, builder: F) -> Vec<T>
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/concurrent/scene_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl SceneProxy {
///
/// Exactly equivalent to:
///
/// ```norun
/// ```no_run
/// scene_proxy.build(build_options);
/// scene_proxy.render(renderer);
/// }
Expand Down