Skip to content

Commit

Permalink
xsnap: platform vs application
Browse files Browse the repository at this point in the history
  • Loading branch information
phoddie committed Apr 19, 2021
1 parent 842ad90 commit c2cebe7
Show file tree
Hide file tree
Showing 10 changed files with 2,132 additions and 1,008 deletions.
130 changes: 130 additions & 0 deletions xsnap/makefiles/lin/xsnap-ava.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
% : %.c
%.o : %.c

GOAL ?= debug
NAME = xsnap
ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
endif

MODDABLE = $(CURDIR)/../../moddable
XS_DIR = $(MODDABLE)/xs
BUILD_DIR = $(CURDIR)/../../build

BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
TLS_DIR = ../../src
TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME)

MACOS_ARCH ?= -arch i386
MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7

C_OPTIONS = \
-fno-common \
-DINCLUDE_XSPLATFORM \
-DXSPLATFORM=\"xsnapPlatform.h\" \
-DXSNAP_VERSION=\"$(XSNAP_VERSION)\" \
-DmxParse=1 \
-DmxRun=1 \
-DmxSloppy=1 \
-DmxSnapshot=1 \
-DmxMetering=1 \
-DmxRegExpUnicodePropertyEscapes=1 \
-I$(INC_DIR) \
-I$(PLT_DIR) \
-I$(SRC_DIR) \
-I$(TLS_DIR) \
-I$(TMP_DIR)
C_OPTIONS += \
-Wno-misleading-indentation \
-Wno-implicit-fallthrough
ifeq ($(GOAL),debug)
C_OPTIONS += -DmxDebug=1 -g -O0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
else
C_OPTIONS += -DmxBoundsCheck=1 -O3
endif

LIBRARIES = -ldl -lm -lpthread

LINK_OPTIONS = -rdynamic

OBJECTS = \
$(TMP_DIR)/xsAll.o \
$(TMP_DIR)/xsAPI.o \
$(TMP_DIR)/xsArguments.o \
$(TMP_DIR)/xsArray.o \
$(TMP_DIR)/xsAtomics.o \
$(TMP_DIR)/xsBigInt.o \
$(TMP_DIR)/xsBoolean.o \
$(TMP_DIR)/xsCode.o \
$(TMP_DIR)/xsCommon.o \
$(TMP_DIR)/xsDataView.o \
$(TMP_DIR)/xsDate.o \
$(TMP_DIR)/xsDebug.o \
$(TMP_DIR)/xsDefaults.o \
$(TMP_DIR)/xsError.o \
$(TMP_DIR)/xsFunction.o \
$(TMP_DIR)/xsGenerator.o \
$(TMP_DIR)/xsGlobal.o \
$(TMP_DIR)/xsJSON.o \
$(TMP_DIR)/xsLexical.o \
$(TMP_DIR)/xsMapSet.o \
$(TMP_DIR)/xsMarshall.o \
$(TMP_DIR)/xsMath.o \
$(TMP_DIR)/xsMemory.o \
$(TMP_DIR)/xsModule.o \
$(TMP_DIR)/xsNumber.o \
$(TMP_DIR)/xsObject.o \
$(TMP_DIR)/xsPlatforms.o \
$(TMP_DIR)/xsProfile.o \
$(TMP_DIR)/xsPromise.o \
$(TMP_DIR)/xsProperty.o \
$(TMP_DIR)/xsProxy.o \
$(TMP_DIR)/xsRegExp.o \
$(TMP_DIR)/xsRun.o \
$(TMP_DIR)/xsScope.o \
$(TMP_DIR)/xsScript.o \
$(TMP_DIR)/xsSnapshot.o \
$(TMP_DIR)/xsSourceMap.o \
$(TMP_DIR)/xsString.o \
$(TMP_DIR)/xsSymbol.o \
$(TMP_DIR)/xsSyntaxical.o \
$(TMP_DIR)/xsTree.o \
$(TMP_DIR)/xsType.o \
$(TMP_DIR)/xsdtoa.o \
$(TMP_DIR)/xsre.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/$(NAME).o

VPATH += $(SRC_DIR) $(TLS_DIR)

build: $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)/$(NAME)

$(TMP_DIR):
mkdir -p $(TMP_DIR)

$(BIN_DIR):
mkdir -p $(BIN_DIR)

$(BIN_DIR)/$(NAME): $(OBJECTS)
@echo "#" $(NAME) $(GOAL) ": cc" $(@F)
$(CC) $(LINK_OPTIONS) $(OBJECTS) $(LIBRARIES) -o $@

$(OBJECTS): $(TLS_DIR)/xsnap.h
$(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
$(OBJECTS): $(PLT_DIR)/xsPlatform.h
$(OBJECTS): $(SRC_DIR)/xsCommon.h
$(OBJECTS): $(SRC_DIR)/xsAll.h
$(OBJECTS): $(SRC_DIR)/xsScript.h
$(OBJECTS): $(SRC_DIR)/xsSnapshot.h
$(TMP_DIR)/%.o: %.c
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
$(CC) $< $(C_OPTIONS) -c -o $@

clean:
rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME)
4 changes: 3 additions & 1 deletion xsnap/makefiles/lin/xsnap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7
C_OPTIONS = \
-fno-common \
-DINCLUDE_XSPLATFORM \
-DXSPLATFORM=\"xsnap.h\" \
-DXSPLATFORM=\"xsnapPlatform.h\" \
-DmxMetering=1 \
-DmxParse=1 \
-DmxRun=1 \
Expand Down Expand Up @@ -93,6 +93,7 @@ OBJECTS = \
$(TMP_DIR)/xsType.o \
$(TMP_DIR)/xsdtoa.o \
$(TMP_DIR)/xsre.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/xsnap.o

VPATH += $(SRC_DIR) $(TLS_DIR)
Expand All @@ -110,6 +111,7 @@ $(BIN_DIR)/$(NAME): $(OBJECTS)
$(CC) $(LINK_OPTIONS) $(OBJECTS) $(LIBRARIES) -o $@

$(OBJECTS): $(TLS_DIR)/xsnap.h
$(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
$(OBJECTS): $(PLT_DIR)/xsPlatform.h
$(OBJECTS): $(SRC_DIR)/xsCommon.h
$(OBJECTS): $(SRC_DIR)/xsAll.h
Expand Down
139 changes: 139 additions & 0 deletions xsnap/makefiles/mac/xsnap-ava.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
% : %.c
%.o : %.c

GOAL ?= debug
NAME = xsnap
ifneq ($(VERBOSE),1)
MAKEFLAGS += --silent
endif

MODDABLE = $(CURDIR)/../../moddable
XS_DIR = $(MODDABLE)/xs
BUILD_DIR = $(CURDIR)/../../build

BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL)
INC_DIR = $(XS_DIR)/includes
PLT_DIR = $(XS_DIR)/platforms
SRC_DIR = $(XS_DIR)/sources
TLS_DIR = ../../src
TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME)

# MACOS_ARCH ?= -arch i386
MACOS_ARCH ?=
MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7

C_OPTIONS = \
-fno-common \
$(MACOS_ARCH) \
$(MACOS_VERSION_MIN) \
-DINCLUDE_XSPLATFORM \
-DXSPLATFORM=\"xsnapPlatform.h\" \
-DXSNAP_VERSION=\"$(XSNAP_VERSION)\" \
-DmxParse=1 \
-DmxRun=1 \
-DmxSloppy=1 \
-DmxSnapshot=1 \
-DmxMetering=1 \
-DmxRegExpUnicodePropertyEscapes=1 \
-I$(INC_DIR) \
-I$(PLT_DIR) \
-I$(SRC_DIR) \
-I$(TLS_DIR) \
-I$(TMP_DIR)
ifneq ("x$(SDKROOT)", "x")
C_OPTIONS += -isysroot $(SDKROOT)
endif
ifeq ($(GOAL),debug)
C_OPTIONS += -DmxDebug=1 -g -O0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
else
C_OPTIONS += -DmxBoundsCheck=1 -O3
endif

LIBRARIES = -framework CoreServices

LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH)
ifneq ("x$(SDKROOT)", "x")
LINK_OPTIONS += -isysroot $(SDKROOT)
endif

# C_OPTIONS += -fsanitize=address -fno-omit-frame-pointer
# LINK_OPTIONS += -fsanitize=address -fno-omit-frame-pointer

OBJECTS = \
$(TMP_DIR)/xsAll.o \
$(TMP_DIR)/xsAPI.o \
$(TMP_DIR)/xsArguments.o \
$(TMP_DIR)/xsArray.o \
$(TMP_DIR)/xsAtomics.o \
$(TMP_DIR)/xsBigInt.o \
$(TMP_DIR)/xsBoolean.o \
$(TMP_DIR)/xsCode.o \
$(TMP_DIR)/xsCommon.o \
$(TMP_DIR)/xsDataView.o \
$(TMP_DIR)/xsDate.o \
$(TMP_DIR)/xsDebug.o \
$(TMP_DIR)/xsDefaults.o \
$(TMP_DIR)/xsError.o \
$(TMP_DIR)/xsFunction.o \
$(TMP_DIR)/xsGenerator.o \
$(TMP_DIR)/xsGlobal.o \
$(TMP_DIR)/xsJSON.o \
$(TMP_DIR)/xsLexical.o \
$(TMP_DIR)/xsMapSet.o \
$(TMP_DIR)/xsMarshall.o \
$(TMP_DIR)/xsMath.o \
$(TMP_DIR)/xsMemory.o \
$(TMP_DIR)/xsModule.o \
$(TMP_DIR)/xsNumber.o \
$(TMP_DIR)/xsObject.o \
$(TMP_DIR)/xsPlatforms.o \
$(TMP_DIR)/xsProfile.o \
$(TMP_DIR)/xsPromise.o \
$(TMP_DIR)/xsProperty.o \
$(TMP_DIR)/xsProxy.o \
$(TMP_DIR)/xsRegExp.o \
$(TMP_DIR)/xsRun.o \
$(TMP_DIR)/xsScope.o \
$(TMP_DIR)/xsScript.o \
$(TMP_DIR)/xsSnapshot.o \
$(TMP_DIR)/xsSourceMap.o \
$(TMP_DIR)/xsString.o \
$(TMP_DIR)/xsSymbol.o \
$(TMP_DIR)/xsSyntaxical.o \
$(TMP_DIR)/xsTree.o \
$(TMP_DIR)/xsType.o \
$(TMP_DIR)/xsdtoa.o \
$(TMP_DIR)/xsre.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/$(NAME).o

VPATH += $(SRC_DIR) $(TLS_DIR)

build: $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)/$(NAME)

$(TMP_DIR):
mkdir -p $(TMP_DIR)

$(BIN_DIR):
mkdir -p $(BIN_DIR)

$(BIN_DIR)/$(NAME): $(OBJECTS)
@echo "#" $(NAME) $(GOAL) ": cc" $(@F)
$(CC) $(LINK_OPTIONS) $(LIBRARIES) $(OBJECTS) -o $@

$(OBJECTS): $(TLS_DIR)/xsnap.h
$(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
$(OBJECTS): $(PLT_DIR)/xsPlatform.h
$(OBJECTS): $(SRC_DIR)/xsCommon.h
$(OBJECTS): $(SRC_DIR)/xsAll.h
$(OBJECTS): $(SRC_DIR)/xsScript.h
$(OBJECTS): $(SRC_DIR)/xsSnapshot.h
$(TMP_DIR)/%.o: %.c
@echo "#" $(NAME) $(GOAL) ": cc" $(<F)
$(CC) $< $(C_OPTIONS) -c -o $@

clean:
rm -rf $(BUILD_DIR)/bin/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/bin/mac/release/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/debug/$(NAME)
rm -rf $(BUILD_DIR)/tmp/mac/release/$(NAME)
4 changes: 3 additions & 1 deletion xsnap/makefiles/mac/xsnap.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ C_OPTIONS = \
$(MACOS_ARCH) \
$(MACOS_VERSION_MIN) \
-DINCLUDE_XSPLATFORM \
-DXSPLATFORM=\"xsnap.h\" \
-DXSPLATFORM=\"xsnapPlatform.h\" \
-DmxMetering=1 \
-DmxParse=1 \
-DmxRun=1 \
Expand Down Expand Up @@ -102,6 +102,7 @@ OBJECTS = \
$(TMP_DIR)/xsType.o \
$(TMP_DIR)/xsdtoa.o \
$(TMP_DIR)/xsre.o \
$(TMP_DIR)/xsnapPlatform.o \
$(TMP_DIR)/xsnap.o

VPATH += $(SRC_DIR) $(TLS_DIR)
Expand All @@ -119,6 +120,7 @@ $(BIN_DIR)/$(NAME): $(OBJECTS)
$(CC) $(LINK_OPTIONS) $(LIBRARIES) $(OBJECTS) -o $@

$(OBJECTS): $(TLS_DIR)/xsnap.h
$(OBJECTS): $(TLS_DIR)/xsnapPlatform.h
$(OBJECTS): $(PLT_DIR)/xsPlatform.h
$(OBJECTS): $(SRC_DIR)/xsCommon.h
$(OBJECTS): $(SRC_DIR)/xsAll.h
Expand Down
4 changes: 3 additions & 1 deletion xsnap/makefiles/win/xsnap.mak
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ C_OPTIONS = \
/D WIN32 \
/D _CRT_SECURE_NO_DEPRECATE \
/D INCLUDE_XSPLATFORM \
/D XSPLATFORM=\"xsnap.h\" \
/D XSPLATFORM=\"xsnapPlatform.h\" \
/D mxMetering=1 \
/D mxParse=1 \
/D mxRun=1 \
Expand Down Expand Up @@ -100,6 +100,7 @@ OBJECTS = \
$(TMP_DIR)\xsType.o \
$(TMP_DIR)\xsdtoa.o \
$(TMP_DIR)\xsre.o \
$(TMP_DIR)\xsnapPlatform.o \
$(TMP_DIR)\xsnap.o

build : $(TMP_DIR) $(BIN_DIR) $(BIN_DIR)\$(NAME).exe
Expand All @@ -119,6 +120,7 @@ $(BIN_DIR)\$(NAME).exe : $(OBJECTS)
/out:$(BIN_DIR)\$(NAME).exe

$(OBJECTS) : $(TLS_DIR)\xsnap.h
$(OBJECTS) : $(TLS_DIR)\xsnapPlatform.h
$(OBJECTS) : $(PLT_DIR)\xsPlatform.h
$(OBJECTS) : $(SRC_DIR)\xsCommon.h
$(OBJECTS) : $(SRC_DIR)\xsAll.h
Expand Down
Loading

0 comments on commit c2cebe7

Please sign in to comment.