Finished getting JerryScript on all the platforms.
This commit is contained in:
@@ -8,6 +8,7 @@ set(JERRY_CMDLINE OFF CACHE BOOL "" FORCE)
|
|||||||
set(JERRY_EXT ON CACHE BOOL "" FORCE)
|
set(JERRY_EXT ON CACHE BOOL "" FORCE)
|
||||||
set(JERRY_DEBUGGER OFF CACHE BOOL "" FORCE)
|
set(JERRY_DEBUGGER OFF CACHE BOOL "" FORCE)
|
||||||
set(JERRY_BUILTIN_DATE OFF CACHE BOOL "" FORCE)
|
set(JERRY_BUILTIN_DATE OFF CACHE BOOL "" FORCE)
|
||||||
|
set(ENABLE_LTO OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
# Fetch Jerry
|
# Fetch Jerry
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -34,12 +35,38 @@ elseif(TARGET jerry-ext)
|
|||||||
set(JERRY_EXT_TARGET jerry-ext)
|
set(JERRY_EXT_TARGET jerry-ext)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET jerryscript-port)
|
if(TARGET jerryscript-port-default)
|
||||||
|
set(JERRY_PORT_TARGET jerryscript-port-default)
|
||||||
|
elseif(TARGET jerry-port-default)
|
||||||
|
set(JERRY_PORT_TARGET jerry-port-default)
|
||||||
|
elseif(TARGET jerryscript-port)
|
||||||
set(JERRY_PORT_TARGET jerryscript-port)
|
set(JERRY_PORT_TARGET jerryscript-port)
|
||||||
elseif(TARGET jerry-port)
|
elseif(TARGET jerry-port)
|
||||||
set(JERRY_PORT_TARGET jerry-port)
|
set(JERRY_PORT_TARGET jerry-port)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT JERRY_CORE_TARGET)
|
||||||
|
message(FATAL_ERROR "JerryScript core target not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT JERRY_EXT_TARGET)
|
||||||
|
message(FATAL_ERROR "JerryScript ext target not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT JERRY_PORT_TARGET)
|
||||||
|
message(FATAL_ERROR "JerryScript port target not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(tgt IN ITEMS
|
||||||
|
${JERRY_CORE_TARGET}
|
||||||
|
${JERRY_EXT_TARGET}
|
||||||
|
${JERRY_PORT_TARGET}
|
||||||
|
)
|
||||||
|
if(TARGET ${tgt})
|
||||||
|
set_property(TARGET ${tgt} PROPERTY INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# Export include dirs through the targets
|
# Export include dirs through the targets
|
||||||
target_include_directories(${JERRY_CORE_TARGET} INTERFACE
|
target_include_directories(${JERRY_CORE_TARGET} INTERFACE
|
||||||
${jerryscript_SOURCE_DIR}/jerry-core/include
|
${jerryscript_SOURCE_DIR}/jerry-core/include
|
||||||
|
|||||||
+20
-3
@@ -1,6 +1,19 @@
|
|||||||
|
# Fixes some problems building JerryScript
|
||||||
|
set(CMAKE_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
||||||
|
set(CMAKE_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
||||||
|
set(CMAKE_C_COMPILER_AR "$ENV{PSPDEV}/bin/psp-ar" CACHE FILEPATH "" FORCE)
|
||||||
|
set(CMAKE_C_COMPILER_RANLIB "$ENV{PSPDEV}/bin/psp-ranlib" CACHE FILEPATH "" FORCE)
|
||||||
|
set(CMAKE_C_ARCHIVE_CREATE "$ENV{PSPDEV}/bin/psp-ar qc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||||
|
set(CMAKE_C_ARCHIVE_APPEND "$ENV{PSPDEV}/bin/psp-ar q <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||||
|
set(CMAKE_C_ARCHIVE_FINISH "$ENV{PSPDEV}/bin/psp-ranlib <TARGET>")
|
||||||
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF CACHE BOOL "" FORCE)
|
||||||
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_C OFF CACHE BOOL "" FORCE)
|
||||||
|
set(JERRY_LTO OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
find_package(jerryscript REQUIRED)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
target_link_libraries(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
SDL2
|
SDL2
|
||||||
pthread
|
pthread
|
||||||
@@ -29,13 +42,17 @@ target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|||||||
pspnet_apctl
|
pspnet_apctl
|
||||||
psphttp
|
psphttp
|
||||||
pspssl
|
pspssl
|
||||||
|
|
||||||
|
jerryscript::core
|
||||||
|
jerryscript::ext
|
||||||
|
jerryscript::port
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
target_include_directories(${DUSK_BINARY_TARGET_NAME} PRIVATE
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
target_compile_definitions(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||||
DUSK_SDL2
|
DUSK_SDL2
|
||||||
DUSK_OPENGL
|
DUSK_OPENGL
|
||||||
DUSK_PSP
|
DUSK_PSP
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ endif()
|
|||||||
|
|
||||||
if(NOT jerryscript_FOUND)
|
if(NOT jerryscript_FOUND)
|
||||||
find_package(jerryscript REQUIRED)
|
find_package(jerryscript REQUIRED)
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||||
jerryscript::core
|
jerryscript::core
|
||||||
jerryscript::ext
|
jerryscript::ext
|
||||||
jerryscript::port
|
jerryscript::port
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void timeUpdate(void) {
|
|||||||
dusktimeepoch_t epoch = timeGetEpoch();
|
dusktimeepoch_t epoch = timeGetEpoch();
|
||||||
char_t buffer[256];
|
char_t buffer[256];
|
||||||
timeEpochFormat(epoch, "%Y-%m-%d %H:%M:%S", buffer, sizeof(buffer));
|
timeEpochFormat(epoch, "%Y-%m-%d %H:%M:%S", buffer, sizeof(buffer));
|
||||||
consolePrint("Real Time: %s", buffer);
|
// consolePrint("Real Time: %s", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
dusktimeepoch_t timeGetEpoch(void) {
|
dusktimeepoch_t timeGetEpoch(void) {
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "timeepoch.h"
|
#include "timeepoch.h"
|
||||||
|
#include "time/timeplatform.h"
|
||||||
|
|
||||||
#ifndef DUSK_TIME_STEP
|
#ifndef DUSK_TIME_STEP
|
||||||
#define DUSK_TIME_STEP (16.0f / 1000.0f)
|
#define DUSK_TIME_STEP (16.0f / 1000.0f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DUSK_TIME_DYNAMIC
|
#ifdef DUSK_TIME_DYNAMIC
|
||||||
#include "time/timeplatform.h"
|
|
||||||
|
|
||||||
#ifndef timeTickPlatform
|
#ifndef timeTickPlatform
|
||||||
#error "DUSK_TIME_DYNAMIC needs tick method defined"
|
#error "DUSK_TIME_DYNAMIC needs tick method defined"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ add_subdirectory(display)
|
|||||||
add_subdirectory(input)
|
add_subdirectory(input)
|
||||||
add_subdirectory(network)
|
add_subdirectory(network)
|
||||||
add_subdirectory(system)
|
add_subdirectory(system)
|
||||||
|
add_subdirectory(time)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
|
PUBLIC
|
||||||
|
timedolphin.c
|
||||||
|
)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "time/timedolphin.h"
|
||||||
|
|
||||||
|
double_t timeGetRealDolphin(void) {
|
||||||
|
// "Returns time in ticks since 2000"
|
||||||
|
u64 timeInMillis = PPCTicksToMs(SYS_Time());
|
||||||
|
double_t timeSeconds = (double_t)timeInMillis / 1000.0;
|
||||||
|
|
||||||
|
// Time to adjust time from 2000 to 1970, in seconds
|
||||||
|
double_t timeOffset = 946684800.0;
|
||||||
|
|
||||||
|
timeSeconds += timeOffset;
|
||||||
|
return timeSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
double_t timeGetRealTimeZoneDolphin(void) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dusk.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the real current time, in seconds since January 1, 1970.
|
||||||
|
*
|
||||||
|
* @return The real current time, in seconds since January 1, 1970.
|
||||||
|
*/
|
||||||
|
double_t timeGetRealDolphin(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the real time zone offset in seconds from UTC.
|
||||||
|
*
|
||||||
|
* @return The real time zone offset in seconds from UTC.
|
||||||
|
*/
|
||||||
|
double_t timeGetRealTimeZoneDolphin(void);
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "time/timedolphin.h"
|
||||||
|
|
||||||
|
#define timeGetRealPlatform timeGetRealDolphin
|
||||||
|
#define timeGetRealTimeZonePlatform timeGetRealTimeZoneDolphin
|
||||||
@@ -20,3 +20,4 @@ add_subdirectory(input)
|
|||||||
add_subdirectory(log)
|
add_subdirectory(log)
|
||||||
add_subdirectory(network)
|
add_subdirectory(network)
|
||||||
add_subdirectory(system)
|
add_subdirectory(system)
|
||||||
|
add_subdirectory(time)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
|
PUBLIC
|
||||||
|
timepsp.c
|
||||||
|
)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "time/timesdl2.h"
|
||||||
|
#include "time/timepsp.h"
|
||||||
|
|
||||||
|
#define timeTickPlatform timeTickSDL2
|
||||||
|
#define timeGetDeltaPlatform timeGetDeltaSDL2
|
||||||
|
#define timeGetRealPlatform timeGetRealPSP
|
||||||
|
#define timeGetRealTimeZonePlatform timeGetRealTimeZonePSP
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "time/timepsp.h"
|
||||||
|
#include <time.h>
|
||||||
|
#include <psptypes.h>
|
||||||
|
#include <psprtc.h>
|
||||||
|
|
||||||
|
double_t timeGetRealPSP(void) {
|
||||||
|
u64 utc_ticks = 0;
|
||||||
|
|
||||||
|
if(sceRtcGetCurrentTick(&utc_ticks) < 0) return 0.0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
PSP RTC ticks are microseconds.
|
||||||
|
Return seconds since 1970-01-01 UTC.
|
||||||
|
*/
|
||||||
|
return (double_t)utc_ticks / 1000000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double_t timeGetRealTimeZonePSP(void) {
|
||||||
|
u64 utc_ticks = 0;
|
||||||
|
u64 local_ticks = 0;
|
||||||
|
|
||||||
|
if(sceRtcGetCurrentTick(&utc_ticks) < 0) return 0.0;
|
||||||
|
if(sceRtcConvertUtcToLocalTime(&utc_ticks, &local_ticks) < 0) return 0.0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Return timezone offset in hours.
|
||||||
|
Example:
|
||||||
|
UTC-6 => -6.0
|
||||||
|
UTC+2 => 2.0
|
||||||
|
*/
|
||||||
|
int64_t offset_us = (int64_t)local_ticks - (int64_t)utc_ticks;
|
||||||
|
return (double_t)offset_us / (1000000.0 * 60.0 * 60.0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dusk.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the real current time, in seconds since January 1, 1970.
|
||||||
|
*
|
||||||
|
* @return The real current time, in seconds since January 1, 1970.
|
||||||
|
*/
|
||||||
|
double_t timeGetRealPSP(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the real time zone offset in seconds from UTC.
|
||||||
|
*
|
||||||
|
* @return The real time zone offset in seconds from UTC.
|
||||||
|
*/
|
||||||
|
double_t timeGetRealTimeZonePSP(void);
|
||||||
Reference in New Issue
Block a user