Tweaks
This commit is contained in:
		
							parent
							
								
									d5b7facf36
								
							
						
					
					
						commit
						833191fbd4
					
				
							
								
								
									
										7
									
								
								build.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								build.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					cd go
 | 
				
			||||||
 | 
					go build -buildmode c-shared -ldflags="-w -s" -trimpath -v -o "go_p2fa.so"
 | 
				
			||||||
 | 
					rm -rf ../c/libs/go_p2fa.h
 | 
				
			||||||
 | 
					cp go_p2fa.h ../c/libs/go_p2fa.h
 | 
				
			||||||
 | 
					cd ../c/src
 | 
				
			||||||
 | 
					make -j1
 | 
				
			||||||
@ -1,18 +0,0 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.10)
 | 
					 | 
				
			||||||
project(P2FA)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
set(CMAKE_C_STANDARD 99)
 | 
					 | 
				
			||||||
set(CMAKE_CXX_STANDARD 11)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
include_directories(${CMAKE_SOURCE_DIR}/libs/include)
 | 
					 | 
				
			||||||
link_directories(${CMAKE_SOURCE_DIR}/libs)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
add_library(p2fa SHARED src/p2fa.c
 | 
					 | 
				
			||||||
        src/images.c)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
target_link_libraries(p2fa)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
set_target_properties(p2fa PROPERTIES
 | 
					 | 
				
			||||||
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build"
 | 
					 | 
				
			||||||
    OUTPUT_NAME "p2fa"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
@ -1,4 +0,0 @@
 | 
				
			|||||||
Get-ChildItem -Path build -Recurse | Remove-Item -force -recurse
 | 
					 | 
				
			||||||
if (Test-Path -Path .\build) { Remove-Item -Path .\build -Recurse -Force }
 | 
					 | 
				
			||||||
cmake -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" -S . -B .\build
 | 
					 | 
				
			||||||
cmake --build .\build --target p2fa -- -j 14
 | 
					 | 
				
			||||||
@ -1,85 +0,0 @@
 | 
				
			|||||||
/* Code generated by cmd/cgo; DO NOT EDIT. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* package P2FA */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#line 1 "cgo-builtin-export-prolog"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stddef.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef GO_CGO_EXPORT_PROLOGUE_H
 | 
					 | 
				
			||||||
#define GO_CGO_EXPORT_PROLOGUE_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
 | 
					 | 
				
			||||||
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Start of preamble from import "C" comments.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* End of preamble from import "C" comments.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Start of boilerplate cgo prologue.  */
 | 
					 | 
				
			||||||
#line 1 "cgo-gcc-export-header-prolog"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef GO_CGO_PROLOGUE_H
 | 
					 | 
				
			||||||
#define GO_CGO_PROLOGUE_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef signed char GoInt8;
 | 
					 | 
				
			||||||
typedef unsigned char GoUint8;
 | 
					 | 
				
			||||||
typedef short GoInt16;
 | 
					 | 
				
			||||||
typedef unsigned short GoUint16;
 | 
					 | 
				
			||||||
typedef int GoInt32;
 | 
					 | 
				
			||||||
typedef unsigned int GoUint32;
 | 
					 | 
				
			||||||
typedef long long GoInt64;
 | 
					 | 
				
			||||||
typedef unsigned long long GoUint64;
 | 
					 | 
				
			||||||
typedef GoInt64 GoInt;
 | 
					 | 
				
			||||||
typedef GoUint64 GoUint;
 | 
					 | 
				
			||||||
typedef size_t GoUintptr;
 | 
					 | 
				
			||||||
typedef float GoFloat32;
 | 
					 | 
				
			||||||
typedef double GoFloat64;
 | 
					 | 
				
			||||||
#ifdef _MSC_VER
 | 
					 | 
				
			||||||
#include <complex.h>
 | 
					 | 
				
			||||||
typedef _Fcomplex GoComplex64;
 | 
					 | 
				
			||||||
typedef _Dcomplex GoComplex128;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
typedef float _Complex GoComplex64;
 | 
					 | 
				
			||||||
typedef double _Complex GoComplex128;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
  static assertion to make sure the file is being used on architecture
 | 
					 | 
				
			||||||
  at least with matching size of GoInt.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
 | 
					 | 
				
			||||||
typedef _GoString_ GoString;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
typedef void *GoMap;
 | 
					 | 
				
			||||||
typedef void *GoChan;
 | 
					 | 
				
			||||||
typedef struct { void *t; void *v; } GoInterface;
 | 
					 | 
				
			||||||
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* End of boilerplate cgo prologue.  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern __declspec(dllexport) void loadConfigs();
 | 
					 | 
				
			||||||
extern __declspec(dllexport) GoSlice getConfigNames();
 | 
					 | 
				
			||||||
extern __declspec(dllexport) GoString getCode(GoString configName);
 | 
					 | 
				
			||||||
extern __declspec(dllexport) GoUint64 getTimeRemaining(GoInt n);
 | 
					 | 
				
			||||||
extern __declspec(dllexport) GoUint64 getTimeRemainingMS(GoInt n);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@ -27,7 +27,8 @@ int draw() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    Paint_Clear(WHITE);
 | 
					    Paint_Clear(WHITE);
 | 
				
			||||||
    const char *confName = "default";
 | 
					    const char *confName = "default";
 | 
				
			||||||
    Paint_DrawString(5, 5, getCode(GoString{confName, strlen(confName)}).p, &Font24, WHITE, BLACK);
 | 
					    GoString confStr = {confName, strlen(confName)};
 | 
				
			||||||
 | 
					    Paint_DrawString(5, 5, getCode(confStr).p, &Font24, WHITE, BLACK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DEV_Delay_ms(5000);
 | 
					    DEV_Delay_ms(5000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										14
									
								
								c/src/p2fa.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								c/src/p2fa.h
									
									
									
									
									
								
							@ -1,14 +0,0 @@
 | 
				
			|||||||
//
 | 
					 | 
				
			||||||
// Created by steven on 11/14/2024.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef P2FA_P2FA_H
 | 
					 | 
				
			||||||
#define P2FA_P2FA_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Handler(int sigNum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//__declspec(dllexport) void init();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__declspec(dllexport) int draw();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif //P2FA_P2FA_H
 | 
					 | 
				
			||||||
@ -146,5 +146,3 @@ func getTimeRemaining(n int) uint64 {
 | 
				
			|||||||
func getTimeRemainingMS(n int) uint64 {
 | 
					func getTimeRemainingMS(n int) uint64 {
 | 
				
			||||||
	return (uint64(n) * 1000) - (uint64(time.Now().UnixNano()/1e6) % (uint64(n) * 1000))
 | 
						return (uint64(n) * 1000) - (uint64(time.Now().UnixNano()/1e6) % (uint64(n) * 1000))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func main() {}
 | 
					 | 
				
			||||||
							
								
								
									
										35
									
								
								go/ui.go.old
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								go/ui.go.old
									
									
									
									
									
								
							@ -1,35 +0,0 @@
 | 
				
			|||||||
package main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
#cgo CFLAGS: -I.
 | 
					 | 
				
			||||||
#cgo LDFLAGS: -L. -llibp2fa
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../c/src/p2fa.h"
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
import "C"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import (
 | 
					 | 
				
			||||||
	"time"
 | 
					 | 
				
			||||||
	"unsafe"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func startUI() {
 | 
					 | 
				
			||||||
	if C.SDL_Init(C.SDL_INIT_VIDEO) != 0 {
 | 
					 | 
				
			||||||
		panic("Failed to initialize SDL")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	defer C.SDL_Quit()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	window := C.createWindow()
 | 
					 | 
				
			||||||
	if window == nil {
 | 
					 | 
				
			||||||
		panic("Error creating window")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	renderer := C.createRenderer((*C.SDL_Window)(unsafe.Pointer(window)))
 | 
					 | 
				
			||||||
	if renderer == nil {
 | 
					 | 
				
			||||||
		panic("Error creating renderer")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	C.draw(renderer)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	time.Sleep(10 * time.Second)
 | 
					 | 
				
			||||||
	C.destroy(renderer, window)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user