Skip to content
Draft
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
102 changes: 16 additions & 86 deletions CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,131 +21,61 @@
# Require CMake 2.8. I know for sure that this will not work with CMake 2.6
# due to the use of the FILE command we use when creating the bundle
# hierarchy.
#cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)

# This is the default from cmake 3.0
# Mac OS X: Setting policy CMP0042 to the new behavior generates dylibs with
# RPATH-relative install name that is better suited for Mac OS X applications
# embedding Io in their bundle.
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()

# Project name, this gets prefixed to a bunch of stuff under the hood. No
# spaces, or anything silly like that please.
project(IoLanguage C)

# Default config when building with gcc variants
IF(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
SET(CMAKE_BUILD_TYPE_DebugFast)
SET(CMAKE_CXX_FLAGS_DEBUGFAST "-g -O0")
SET(CMAKE_C_FLAGS_DEBUGFAST "-g -O0")

IF((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
SET(CMAKE_C_FLAGS_DEBUGFAST "-g -O")
if (NOT DEFINED HAS_SSE2)
cmake_host_system_information(RESULT HAS_SSE2 QUERY HAS_SSE2)
endif()
# Only use -msse2 flag for x86/x86_64 architectures.
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
if(HAS_SSE2)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
endif()

if(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DebugFast")
endif(NOT CMAKE_BUILD_TYPE)
ENDIF(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
ENDIF()

MESSAGE(STATUS "Configuration set to: ${CMAKE_BUILD_TYPE}")

# Don't want a coloured Makefile. On some platforms, the blue that is used is
# so dark it's illegible.
set(CMAKE_COLOR_MAKEFILE off)

# We want our binaries to go here
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/_build/binaries)

# Macro to create the _build directory hierarchy.
# Note: I'm not sure we need lib/ or objs/ in there. But I'll leave them in
# anyway, I'm just not going to do anything with them unless it breaks doing
# nothing breaks something.
macro(make_build_bundle NAME)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/binaries ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/objs ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/headers ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/lib ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/dll)
endmacro(make_build_bundle)

# Generic macro to copy files mattching GLOBPAT in the current source
# directory into another directory.
macro(copy_files NAME GLOBPAT DSTDIR)
# Get a list of the filenames mattching the pattern GLOBPAT
file(GLOB ${NAME} ${GLOBPAT})

# Create a custom copy target and display a message
add_custom_target(copy_${NAME} ALL COMMENT "Copying files: ${CMAKE_CURRENT_SOURCE_DIR}/${GLOBPAT} to ${DSTDIR}")

foreach(FILENAME ${${NAME}})
# Finally, copy the files.
add_custom_command(
TARGET copy_${NAME}
COMMAND ${CMAKE_COMMAND} -E copy ${FILENAME} ${DSTDIR}
)
endforeach(FILENAME)
endmacro(copy_files)

# Binary suffix is used to append things like .exe to binary names, for
# windows support.
# Set library prefix to "lib" on Windows
# to match unix.
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(BINARY_SUFFIX ".exe")
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
set(CMAKE_IMPORT_LIBRARY_PREFIX "lib")
else()
set(BINARY_SUFFIX "")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

# Definitions on where we can find headers and whatnot. Convenience definitions.
set(BASEKIT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/libs/basekit/source)
set(GARBAGECOLLECTOR_SOURCE_DIR ${PROJECT_SOURCE_DIR}/libs/garbagecollector/source)
set(IOVM_SOURCE_DIR ${PROJECT_SOURCE_DIR}/libs/iovm/source)
set(PARSON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/deps/parson)

# Subdirectories. These directories should have their own CMakeLists.txt.
add_subdirectory(libs)
add_subdirectory(tools)

# Ensure the _build hierarchy is created top-level, this is where our
# binaries go.
make_build_bundle(_build)

# Next we NEED to copy all the libs headers into one single dir in the bundle.
copy_files(basekit_headers ${PROJECT_SOURCE_DIR}/libs/basekit/source/*.h ${CMAKE_CURRENT_BINARY_DIR}/_build/headers)
copy_files(garbagecollector_headers ${PROJECT_SOURCE_DIR}/libs/garbagecollector/source/*.h ${CMAKE_CURRENT_BINARY_DIR}/_build/headers)
copy_files(iovm_headers ${PROJECT_SOURCE_DIR}/libs/iovm/source/*.h ${CMAKE_CURRENT_BINARY_DIR}/_build/headers)

# Packaging stuff

#Modified from: http://www.mail-archive.com/cmake@cmake.org/msg32916.html
MACRO (TODAY RESULT)
IF (WIN32)
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT}
${${RESULT}})
ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT}
${${RESULT}})
ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} 00.00.0000)
ENDIF (WIN32)
ENDMACRO (TODAY)

TODAY(CMD_DATE)
STRING(SUBSTRING ${CMD_DATE} 0 2 CMD_DATE_DAY)
STRING(SUBSTRING ${CMD_DATE} 3 2 CMD_DATE_MON)
STRING(SUBSTRING ${CMD_DATE} 6 4 CMD_DATE_YEAR)
SET(CMD_DATE "${CMD_DATE_YEAR}.${CMD_DATE_MON}.${CMD_DATE_DAY}")

# If source tree is not a git repository this will not work
#IF(WIN32 AND NOT CYGWIN)
# execute_process(COMMAND "cmd" " /C git rev-parse --short HEAD" OUTPUT_VARIABLE IO_GIT_REV)
#ELSE(WIN32 AND NOT CYGWIN)
# execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE IO_GIT_REV)
#ENDIF(WIN32 AND NOT CYGWIN)
#string(REGEX REPLACE "(.......)." "\\1" IO_GIT_REV ${IO_GIT_REV})
string(TIMESTAMP CMD_DATE_YEAR "%Y")
string(TIMESTAMP CMD_DATE_MON "%m")
string(TIMESTAMP CMD_DATE_DAY "%d")
string(TIMESTAMP CMD_DATE "%Y.%m.%d")

SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
SET(CPACK_PACKAGE_VENDOR "iolanguage.com")
Expand Down
87 changes: 9 additions & 78 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,89 +1,20 @@
# Base Io build system
# Written by Jeremy Tregunna <jeremy.tregunna@me.com>
#
# This file is a stub, here only as required.
#
# CMake file for libs subdirectory.
#

# Add a definition -- explicitly required on Windows, but shouldn't
# hurt other platforms. If it does, let me know.
add_definitions("-DBUILDING_IOVMALL_DLL")

# Output our static library to the top-level _build hierarchy
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/_build/lib)

# Our Io source files to be "compiled" into a C source file.
#file(GLOB IO_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/iovm/io/*.io")
set(IO_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/io/List_bootstrap.io
${CMAKE_CURRENT_SOURCE_DIR}/io/OperatorTable.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Object.io
${CMAKE_CURRENT_SOURCE_DIR}/io/List.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Exception.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Actor.io
${CMAKE_CURRENT_SOURCE_DIR}/io/AddonLoader.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Sequence.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Block.io
${CMAKE_CURRENT_SOURCE_DIR}/io/CFunction.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Date.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Debugger.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Directory.io
${CMAKE_CURRENT_SOURCE_DIR}/io/DynLib.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Error.io
${CMAKE_CURRENT_SOURCE_DIR}/io/File.io
${CMAKE_CURRENT_SOURCE_DIR}/io/List_schwartzian.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Map.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Message.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Number.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Profiler.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Sandbox.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Serialize.io
${CMAKE_CURRENT_SOURCE_DIR}/io/System.io
${CMAKE_CURRENT_SOURCE_DIR}/io/UnitTest.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Vector.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Path.io
${CMAKE_CURRENT_SOURCE_DIR}/io/CLI.io
${CMAKE_CURRENT_SOURCE_DIR}/io/Importer.io
)

# Object files from every lib. Used to create iovmall static library.
file(GLOB BASEKIT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/basekit/source/*.c")
file(GLOB GARBAGECOLLECTOR_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/garbagecollector/source/*.c")
file(GLOB IOVM_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/iovm/source/*.c")
list(REMOVE_ITEM IOVM_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/iovm/source/IoState_iterative_fast.c")
list(APPEND IOVM_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../deps/parson/parson.c)

# Marvelous flags, likely compiler dependent.
#add_definitions(-DBUILDING_IOVM_DLL)# -DINSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")

set(IOVMALL_STATIC_SRCS
${BASEKIT_SRCS}
${GARBAGECOLLECTOR_SRCS}
${IOVM_SRCS}
)

# The custom command to generate source/IoVMInit.c which is our
# "compiled" Io to C source code.
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/iovm/source/IoVMInit.c
COMMAND ${PROJECT_BINARY_DIR}/_build/binaries/io2c VMCode IoState_doString_ ${IO_SRCS} > ${CMAKE_CURRENT_SOURCE_DIR}/iovm/source/IoVMInit.c
DEPENDS io2c
)

# Include dirs, -I flags and whatnot
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/iovm/source
${CMAKE_CURRENT_SOURCE_DIR}/../deps/parson
${CMAKE_CURRENT_SOURCE_DIR}/basekit/source
${CMAKE_CURRENT_SOURCE_DIR}/basekit/source/simd_cph/include
${CMAKE_CURRENT_SOURCE_DIR}/garbagecollector/source
)

# Add a file to our library sources.
list(APPEND IOVMALL_STATIC_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/iovm/source/IoVMInit.c) # Because we generate it

# ...And the static library. Refer to IOVMALL_STATIC_SRCS definition
# up top.
add_library(iovmall_static STATIC ${IOVMALL_STATIC_SRCS})
add_dependencies(iovmall_static io2c basekit garbagecollector iovmall)
# Hackery for CMake's horrible ASM support
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# Always include asm.S for all architectures
set(ASM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/coroutine/source/asm.S)
set_source_files_properties(${ASM_SOURCES} PROPERTIES LANGUAGE C)
endif()

# Define the subdirectories we can reach from here that we want
# to go into and build stuff.
Expand Down
36 changes: 15 additions & 21 deletions libs/basekit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
#
# Build the garbage collector library.

# Output our dynamic library to the top-level _build hierarchy
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/_build/dll)

# Marvelous flags, likely compiler dependent.
add_definitions("-DBUILDING_BASEKIT_DLL")

# Include dirs, -I flags and whatnot
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/simd_cph/include)

set(BASEKIT_LIBS)
set(BASEKIT_LIBS ${CMAKE_DL_LIBS})

# Add dynamic loader library for those who need it
if(${CMAKE_SYSTEM_NAME} MATCHES "(Darwin|Linux|SunOS|syllable)")
list(APPEND BASEKIT_LIBS dl m)
endif(${CMAKE_SYSTEM_NAME} MATCHES "(Darwin|Linux|SunOS|syllable)")
# Add math library for those who need it
find_library(MATH_LIBRARY m)
if (MATH_LIBRARY)
list(APPEND BASEKIT_LIBS ${MATH_LIBRARY})
endif()

# Our library sources.
file(GLOB SRCS "source/*.c")
Expand All @@ -28,19 +26,15 @@ add_library(basekit SHARED ${SRCS})
set_target_properties(basekit PROPERTIES PUBLIC_HEADER "${HEADERS}")
target_link_libraries(basekit ${BASEKIT_LIBS})

# ...And the static library
#add_library(basekit_static STATIC ${SRCS})
# Now build the static library
add_library(basekit_static STATIC ${SRCS})
set_target_properties(basekit_static PROPERTIES PUBLIC_HEADER "${HEADERS}")
target_link_libraries(basekit_static ${BASEKIT_LIBS})

# The following add the install target, so we put libbasekit.* in our
# install prefix.
if(WIN32)
install(TARGETS basekit
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
PUBLIC_HEADER DESTINATION include/io
)
else()
install(TARGETS basekit
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/io
)
endif(WIN32)
install (
TARGETS basekit
FILE_SET HEADERS
)

3 changes: 2 additions & 1 deletion libs/basekit/source/CHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
#include "Common.h"
#include <stddef.h>
#include "PortableStdint.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

#define CHASH_MAXLOOP 5

typedef int(CHashEqualFunc)(void *, void *);
typedef bool(CHashEqualFunc)(void *, void *);
typedef intptr_t(CHashHashFunc)(void *);

typedef struct {
Expand Down
7 changes: 5 additions & 2 deletions libs/basekit/source/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ These defines are helpful for doing OS specific checks in the code.
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)
#include <inttypes.h>
#elif !defined(__SYMBIAN32__) && !defined(_MSC_VER) && !defined(__NeXT__)
#elif !defined(__SYMBIAN32__) && !defined(__NeXT__)
#include <stdint.h>
#else
typedef unsigned char uint8_t;
Expand Down Expand Up @@ -70,7 +70,10 @@ typedef long long int64_t;
#if defined(WIN32) || defined(__WINS__) || defined(__MINGW32__) || \
defined(_MSC_VER)
#define inline __inline
#define snprintf _snprintf
// Do not do this on UCRT (Windows 10 and later)
//#define snprintf _snprintf
// Needed as Windows stdint.h does not have ssize_t
typedef ptrdiff_t ssize_t;
#ifndef __MINGW32__
#define usleep(x) Sleep(((x) + 999) / 1000)
#endif
Expand Down
Loading
Loading