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

Support MacOS #20

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ COMPONENT_SRCDIRS := \

COMPONENT_INCDIRS := \
src/include \
$(JERRYSCRIPT_ROOT)

EXTRA_INCDIR := \
$(JERRYSCRIPT_ROOT)/jerry-core \
$(JERRYSCRIPT_SRCDIRS)

Expand Down Expand Up @@ -137,6 +140,12 @@ endif

JERRY_TYPES_H := $(COMPONENT_PATH)/src/include/Jerryscript/.typemaps.h

ifeq ($(UNAME),Darwin)
SED ?= gsed
else
SED ?= sed
endif

# Generate MAP #define for a jerryscript C enumeration
# $1 -> e.g. JERRY_FUNCTION_TYPE_
# $2 -> source file
Expand All @@ -145,7 +154,7 @@ define JerryGetTypes
$(Q) printf "#define $(if $3,$3_,$1)MAP(XX)" >> $@
$(Q) $(foreach v,\
$(shell $(AWK) -F " |,|=" '/$1/ { sub(/^ +$1/,""); print $$1 }' $(JERRYSCRIPT_ROOT)/jerry-core/include/jerryscript-$2.h),\
printf " \\\\\n\tXX($1$v, %s)" $$( echo "$v" | sed -E 's/(.*)/\L\1/; s/(^|_)([a-z0-9])/\U\2/g' ) >> $@; )
printf " \\\\\n\tXX($1$v, %s)" $$( echo "$v" | $(SED) -E 's/(.*)/\L\1/; s/(^|_)([a-z0-9])/\U\2/g' ) >> $@; )
$(Q) printf "\n\n" >> $@
endef

Expand Down
3 changes: 1 addition & 2 deletions src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

#include "include/Jerryscript/Context.h"
#include <jerryscript.h>

namespace Jerryscript
{
Expand All @@ -23,7 +22,7 @@ Context::Context() : Context(JERRY_GLOBAL_HEAP_SIZE * 1024)

Context::Context(size_t heapSize)
{
auto ctx = jerry_create_context(std::max(heapSize, 1024U), alloc, this);
auto ctx = jerry_create_context(std::max(heapSize, size_t(1024U)), alloc, this);
context.reset(reinterpret_cast<uint8_t*>(ctx));
}

Expand Down
5 changes: 2 additions & 3 deletions src/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

#include "include/Jerryscript/Debug.h"
#include <jerryscript.h>
#include <debug_progmem.h>

namespace Jerryscript
Expand All @@ -21,8 +20,8 @@ bool printHeap()
return false;
}

m_printf(_F("[JS] Heap size %u, allocated %u, peak %u\r\n"), stats.size, stats.allocated_bytes,
stats.peak_allocated_bytes);
m_printf(_F("[JS] Heap size %u, allocated %u, peak %u\r\n"), unsigned(stats.size), unsigned(stats.allocated_bytes),
unsigned(stats.peak_allocated_bytes));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <debug_progmem.h>

extern "C" {
#include <ecma/base/ecma-helpers.h>
#include <jerry-core/ecma/base/ecma-helpers.h>
}

// Check Ecma values are correct
Expand Down
8 changes: 0 additions & 8 deletions src/include/Jerryscript.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#pragma once

#ifdef __cplusplus

#include "Jerryscript/Task.h"
#include "Jerryscript/Debug.h"
#include "Jerryscript/Function.h"
#include "Jerryscript/Except.h"
#include "Jerryscript/Context.h"

#else

#include_next <jerryscript.h>

#endif
2 changes: 1 addition & 1 deletion src/include/Jerryscript/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include <include/jerryscript.h>
#include <jerry-core/include/jerryscript.h>

namespace Jerryscript
{
Expand Down
2 changes: 1 addition & 1 deletion src/include/Jerryscript/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#pragma once

#include <include/jerryscript.h>
#include <jerry-core/include/jerryscript.h>
#include ".typemaps.h"
#include <WString.h>
#include <WVector.h>
Expand Down
4 changes: 2 additions & 2 deletions src/jerry-port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#include "include/Jerryscript/Except.h"
#include "include/Jerryscript/Context.h"
#include <include/jerryscript-port.h>
#include <include/jerryscript-core.h>
#include <jerry-core/include/jerryscript-port.h>
#include <jerry-core/include/jerryscript-core.h>
#include "include/jerry_port_vm.h"
#include <debug_progmem.h>
#include <Platform/RTC.h>
Expand Down
1 change: 0 additions & 1 deletion test/modules/types.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <JerryTest.h>
#include <jcontext.h>

namespace
{
Expand Down