Compare commits
10 Commits
1a311b3796
...
8843f2d2a9
| Author | SHA1 | Date | |
|---|---|---|---|
| 8843f2d2a9 | |||
| 187296ca62 | |||
| b9a3caf033 | |||
| 8e2eec973a | |||
| 6548c3283b | |||
| 4a087d1000 | |||
| da2777717c | |||
| 290caf7aef | |||
| 73ff8ba6aa | |||
| ee6fdfbc48 |
@@ -11,6 +11,10 @@ if (NOT DEFINED bshell_verbose)
|
|||||||
set(bshell_verbose 0)
|
set(bshell_verbose 0)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (NOT DEFINED bshell_enable_floating_point)
|
||||||
|
set(bshell_enable_floating_point 1)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(required_fx_assemblies fx.runtime fx.collections)
|
set(required_fx_assemblies fx.runtime fx.collections)
|
||||||
|
|
||||||
if (bshell_interactive)
|
if (bshell_interactive)
|
||||||
@@ -23,6 +27,7 @@ find_package(FX REQUIRED COMPONENTS ${required_fx_assemblies})
|
|||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${Python_EXECUTABLE}
|
COMMAND ${Python_EXECUTABLE}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/build-id.py
|
${CMAKE_CURRENT_SOURCE_DIR}/tools/build-id.py
|
||||||
|
--source-dir "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
OUTPUT_VARIABLE bshell_version)
|
OUTPUT_VARIABLE bshell_version)
|
||||||
message(STATUS "B Shell version: ${bshell_version}")
|
message(STATUS "B Shell version: ${bshell_version}")
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ add_library(bshell.core SHARED ${sources})
|
|||||||
target_link_libraries(bshell.core bshell.runtime FX::Runtime FX::Collections)
|
target_link_libraries(bshell.core bshell.runtime FX::Runtime FX::Collections)
|
||||||
target_include_directories(bshell.core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(bshell.core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_compile_definitions(bshell.core PUBLIC
|
target_compile_definitions(bshell.core PUBLIC
|
||||||
|
BSHELL_ENABLE_FLOATING_POINT=${bshell_enable_floating_point}
|
||||||
BSHELL_VERSION="${bshell_version}")
|
BSHELL_VERSION="${bshell_version}")
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ endif ()
|
|||||||
target_include_directories(bshell.runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(bshell.runtime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
target_compile_definitions(bshell.runtime PUBLIC
|
target_compile_definitions(bshell.runtime PUBLIC
|
||||||
BSHELL_VERSION="${bshell_version}"
|
BSHELL_VERSION="${bshell_version}"
|
||||||
|
BSHELL_ENABLE_FLOATING_POINT=${bshell_enable_floating_point}
|
||||||
BSHELL_INTERACTIVE=${bshell_interactive}
|
BSHELL_INTERACTIVE=${bshell_interactive}
|
||||||
BSHELL_VERBOSE=${bshell_verbose})
|
BSHELL_VERBOSE=${bshell_verbose})
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
#include <bshell/format.h>
|
#include <bshell/format.h>
|
||||||
#include <fx/term/print.h>
|
|
||||||
#include <fx/type.h>
|
#include <fx/type.h>
|
||||||
#include <fx/value-type.h>
|
#include <fx/value-type.h>
|
||||||
|
|
||||||
|
#if BSHELL_INTERACTIVE == 1
|
||||||
|
#include <fx/term/print.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static void format_value_fallback(const fx_value *value, fx_stream *dest)
|
static void format_value_fallback(const fx_value *value, fx_stream *dest)
|
||||||
{
|
{
|
||||||
#if BSHELL_INTERACTIVE == 1
|
#if BSHELL_INTERACTIVE == 1
|
||||||
|
|||||||
@@ -3,9 +3,12 @@
|
|||||||
#include <fx/iterator.h>
|
#include <fx/iterator.h>
|
||||||
#include <fx/reflection/type.h>
|
#include <fx/reflection/type.h>
|
||||||
#include <fx/stringstream.h>
|
#include <fx/stringstream.h>
|
||||||
|
#include <fx/value.h>
|
||||||
|
|
||||||
|
#if BSHELL_INTERACTIVE == 1
|
||||||
#include <fx/term/print.h>
|
#include <fx/term/print.h>
|
||||||
#include <fx/term/tty.h>
|
#include <fx/term/tty.h>
|
||||||
#include <fx/value.h>
|
#endif
|
||||||
|
|
||||||
static fx_namemap bshell_tables = FX_NAMEMAP_INIT;
|
static fx_namemap bshell_tables = FX_NAMEMAP_INIT;
|
||||||
|
|
||||||
|
|||||||
@@ -20,5 +20,6 @@ enum bshell_status {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern enum bshell_status bshell_status_from_errno(int err);
|
extern enum bshell_status bshell_status_from_errno(int err);
|
||||||
|
extern const char *bshell_status_get_description(int err);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -653,6 +653,7 @@ bool string_is_valid_number(
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *ep = NULL;
|
char *ep = NULL;
|
||||||
|
#if BSHELL_ENABLE_FLOATING_POINT == 1
|
||||||
double dvalue = strtod(s, &ep);
|
double dvalue = strtod(s, &ep);
|
||||||
if (string_could_be_double(s) && *ep == '\0') {
|
if (string_could_be_double(s) && *ep == '\0') {
|
||||||
if (out) {
|
if (out) {
|
||||||
@@ -665,6 +666,7 @@ bool string_is_valid_number(
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int base = get_int_base_by_prefix(&s);
|
int base = get_int_base_by_prefix(&s);
|
||||||
|
|
||||||
@@ -1178,13 +1180,13 @@ int compare_token_types(unsigned int a, unsigned int b)
|
|||||||
|
|
||||||
if (BETWEEN(a, __BSHELL_KW_INDEX_BASE, __BSHELL_KW_INDEX_LIMIT)) {
|
if (BETWEEN(a, __BSHELL_KW_INDEX_BASE, __BSHELL_KW_INDEX_LIMIT)) {
|
||||||
a_type = BSHELL_TOK_KEYWORD;
|
a_type = BSHELL_TOK_KEYWORD;
|
||||||
} else if (BETWEEN(a,
|
} else if (
|
||||||
__BSHELL_TKOP_INDEX_BASE,
|
BETWEEN(a,
|
||||||
__BSHELL_TKOP_INDEX_LIMIT)) {
|
__BSHELL_TKOP_INDEX_BASE,
|
||||||
|
__BSHELL_TKOP_INDEX_LIMIT)) {
|
||||||
a_type = BSHELL_TOK_OPERATOR;
|
a_type = BSHELL_TOK_OPERATOR;
|
||||||
} else if (BETWEEN(a,
|
} else if (
|
||||||
__BSHELL_SYM_INDEX_BASE,
|
BETWEEN(a, __BSHELL_SYM_INDEX_BASE, __BSHELL_SYM_INDEX_LIMIT)) {
|
||||||
__BSHELL_SYM_INDEX_LIMIT)) {
|
|
||||||
a_type = BSHELL_TOK_SYMBOL;
|
a_type = BSHELL_TOK_SYMBOL;
|
||||||
} else {
|
} else {
|
||||||
a_type = a;
|
a_type = a;
|
||||||
@@ -1192,13 +1194,13 @@ int compare_token_types(unsigned int a, unsigned int b)
|
|||||||
|
|
||||||
if (BETWEEN(b, __BSHELL_KW_INDEX_BASE, __BSHELL_KW_INDEX_LIMIT)) {
|
if (BETWEEN(b, __BSHELL_KW_INDEX_BASE, __BSHELL_KW_INDEX_LIMIT)) {
|
||||||
b_type = BSHELL_TOK_KEYWORD;
|
b_type = BSHELL_TOK_KEYWORD;
|
||||||
} else if (BETWEEN(b,
|
} else if (
|
||||||
__BSHELL_TKOP_INDEX_BASE,
|
BETWEEN(b,
|
||||||
__BSHELL_TKOP_INDEX_LIMIT)) {
|
__BSHELL_TKOP_INDEX_BASE,
|
||||||
|
__BSHELL_TKOP_INDEX_LIMIT)) {
|
||||||
b_type = BSHELL_TOK_OPERATOR;
|
b_type = BSHELL_TOK_OPERATOR;
|
||||||
} else if (BETWEEN(b,
|
} else if (
|
||||||
__BSHELL_SYM_INDEX_BASE,
|
BETWEEN(b, __BSHELL_SYM_INDEX_BASE, __BSHELL_SYM_INDEX_LIMIT)) {
|
||||||
__BSHELL_SYM_INDEX_LIMIT)) {
|
|
||||||
b_type = BSHELL_TOK_SYMBOL;
|
b_type = BSHELL_TOK_SYMBOL;
|
||||||
} else {
|
} else {
|
||||||
b_type = b;
|
b_type = b;
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
#include <fx/reflection/function.h>
|
#include <fx/reflection/function.h>
|
||||||
#include <fx/reflection/type.h>
|
#include <fx/reflection/type.h>
|
||||||
#include <fx/string.h>
|
#include <fx/string.h>
|
||||||
#include <fx/term/print.h>
|
|
||||||
#include <fx/vector.h>
|
#include <fx/vector.h>
|
||||||
|
|
||||||
|
#if BSHELL_INTERACTIVE == 1
|
||||||
|
#include <fx/term/print.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum cmdcall_type {
|
enum cmdcall_type {
|
||||||
CMDCALL_NONE = 0,
|
CMDCALL_NONE = 0,
|
||||||
CMDCALL_CMDLET,
|
CMDCALL_CMDLET,
|
||||||
|
|||||||
@@ -17,3 +17,41 @@ enum bshell_status bshell_status_from_errno(int err)
|
|||||||
return BSHELL_ERR_INTERNAL_FAILURE;
|
return BSHELL_ERR_INTERNAL_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *bshell_status_get_description(int err)
|
||||||
|
{
|
||||||
|
switch (err) {
|
||||||
|
case BSHELL_SUCCESS:
|
||||||
|
return "Success";
|
||||||
|
case BSHELL_ERR_EOF:
|
||||||
|
return "Unexpected end-of-file";
|
||||||
|
case BSHELL_ERR_BAD_SYNTAX:
|
||||||
|
return "Bad syntax";
|
||||||
|
case BSHELL_ERR_BAD_FORMAT:
|
||||||
|
return "Bad data format";
|
||||||
|
case BSHELL_ERR_BAD_STATE:
|
||||||
|
return "Object is in bad state";
|
||||||
|
case BSHELL_ERR_INVALID_VALUE:
|
||||||
|
return "Invalid value";
|
||||||
|
case BSHELL_ERR_INVALID_ARGUMENT:
|
||||||
|
return "Invalid argument";
|
||||||
|
case BSHELL_ERR_NO_MEMORY:
|
||||||
|
return "Out of memory";
|
||||||
|
case BSHELL_ERR_NO_ENTRY:
|
||||||
|
return "No such file or directory";
|
||||||
|
case BSHELL_ERR_NO_DATA:
|
||||||
|
return "No data available";
|
||||||
|
case BSHELL_ERR_NAME_EXISTS:
|
||||||
|
return "File or object already exists";
|
||||||
|
case BSHELL_ERR_NOT_SUPPORTED:
|
||||||
|
return "Operation not supported";
|
||||||
|
case BSHELL_ERR_IO_FAILURE:
|
||||||
|
return "I/O failure";
|
||||||
|
case BSHELL_ERR_ACCESS_DENIED:
|
||||||
|
return "Access denied";
|
||||||
|
case BSHELL_ERR_INTERNAL_FAILURE:
|
||||||
|
return "Internal failure";
|
||||||
|
default:
|
||||||
|
return "Unknown error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ target_link_libraries(bshell
|
|||||||
if (bshell_interactive)
|
if (bshell_interactive)
|
||||||
target_link_libraries(bshell FX::Term)
|
target_link_libraries(bshell FX::Term)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_compile_definitions(bshell PUBLIC
|
target_compile_definitions(bshell PUBLIC
|
||||||
BSHELL_VERSION="${bshell_version}"
|
BSHELL_VERSION="${bshell_version}"
|
||||||
|
BSHELL_ENABLE_FLOATING_POINT=${bshell_enable_floating_point}
|
||||||
BSHELL_INTERACTIVE=${bshell_interactive}
|
BSHELL_INTERACTIVE=${bshell_interactive}
|
||||||
BSHELL_VERBOSE=${bshell_verbose})
|
BSHELL_VERBOSE=${bshell_verbose})
|
||||||
|
|||||||
+4
-1
@@ -5,9 +5,12 @@
|
|||||||
#include <bshell/runtime/opcode.h>
|
#include <bshell/runtime/opcode.h>
|
||||||
#include <bshell/runtime/script-block.h>
|
#include <bshell/runtime/script-block.h>
|
||||||
#include <fx/string.h>
|
#include <fx/string.h>
|
||||||
#include <fx/term/print.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if BSHELL_INTERACTIVE == 1
|
||||||
|
#include <fx/term/print.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BSHELL_INTERACTIVE == 1
|
#if BSHELL_INTERACTIVE == 1
|
||||||
#define RED "[red]"
|
#define RED "[red]"
|
||||||
#define YELLOW "[yellow]"
|
#define YELLOW "[yellow]"
|
||||||
|
|||||||
+13
-1
@@ -1,5 +1,4 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "line-ed/line-ed.h"
|
|
||||||
|
|
||||||
#include <bshell/ast.h>
|
#include <bshell/ast.h>
|
||||||
#include <bshell/compile.h>
|
#include <bshell/compile.h>
|
||||||
@@ -12,6 +11,10 @@
|
|||||||
#include <bshell/verb.h>
|
#include <bshell/verb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if BSHELL_INTERACTIVE == 1
|
||||||
|
#include "line-ed/line-ed.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const fx_assembly *bshell_assembly_get(void);
|
extern const fx_assembly *bshell_assembly_get(void);
|
||||||
extern const fx_assembly *bshell_runtime_assembly_get(void);
|
extern const fx_assembly *bshell_runtime_assembly_get(void);
|
||||||
extern const fx_assembly *bshell_core_assembly_get(void);
|
extern const fx_assembly *bshell_core_assembly_get(void);
|
||||||
@@ -74,6 +77,15 @@ int main(int argc, const char **argv)
|
|||||||
status = bshell_file_open(argv[1], &file);
|
status = bshell_file_open(argv[1], &file);
|
||||||
linesrc = &file->f_base;
|
linesrc = &file->f_base;
|
||||||
interactive = false;
|
interactive = false;
|
||||||
|
|
||||||
|
if (!FX_OK(status)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: cannot open '%s': %s\n",
|
||||||
|
argv[0],
|
||||||
|
argv[1],
|
||||||
|
bshell_status_get_description(status));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
#if BSHELL_INTERACTIVE == 1
|
#if BSHELL_INTERACTIVE == 1
|
||||||
ed = line_ed_create();
|
ed = line_ed_create();
|
||||||
|
|||||||
+31
-23
@@ -51,15 +51,7 @@ endif ()
|
|||||||
|
|
||||||
set(assemblies ${FX_FIND_COMPONENTS})
|
set(assemblies ${FX_FIND_COMPONENTS})
|
||||||
set(required_vars)
|
set(required_vars)
|
||||||
|
set(in_tree FALSE)
|
||||||
if (NOT FX_INCLUDE_DIR)
|
|
||||||
find_path(FX_INCLUDE_DIR
|
|
||||||
NAMES fx/misc.h ${FX_FIND_ARGS}
|
|
||||||
PATH_SUFFIXES include
|
|
||||||
PATHS ${FX_SEARCH_PATHS})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(required_vars FX_INCLUDE_DIR)
|
|
||||||
|
|
||||||
foreach (assembly ${assemblies})
|
foreach (assembly ${assemblies})
|
||||||
string(TOLOWER ${assembly} header_name)
|
string(TOLOWER ${assembly} header_name)
|
||||||
@@ -69,10 +61,15 @@ foreach (assembly ${assemblies})
|
|||||||
set(lib_name ${assembly}${_lib_suffix})
|
set(lib_name ${assembly}${_lib_suffix})
|
||||||
|
|
||||||
if (NOT ${macro_name}_LIBRARY)
|
if (NOT ${macro_name}_LIBRARY)
|
||||||
find_library(${macro_name}_LIBRARY
|
if (TARGET ${assembly})
|
||||||
NAMES ${lib_name} ${FX_FIND_ARGS}
|
set (${macro_name}_LIBRARY ${assembly})
|
||||||
PATH_SUFFIXES lib
|
set(in_tree TRUE)
|
||||||
PATHS ${FX_SEARCH_PATHS})
|
else ()
|
||||||
|
find_library(${macro_name}_LIBRARY
|
||||||
|
NAMES ${lib_name} ${FX_FIND_ARGS}
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
PATHS ${FX_SEARCH_PATHS})
|
||||||
|
endif ()
|
||||||
else ()
|
else ()
|
||||||
# on Windows, ensure paths are in canonical format (forward slahes):
|
# on Windows, ensure paths are in canonical format (forward slahes):
|
||||||
file(TO_CMAKE_PATH "${${macro_name}_LIBRARY}" ${macro_name}_LIBRARY)
|
file(TO_CMAKE_PATH "${${macro_name}_LIBRARY}" ${macro_name}_LIBRARY)
|
||||||
@@ -81,6 +78,14 @@ foreach (assembly ${assemblies})
|
|||||||
list(APPEND required_vars ${macro_name}_LIBRARY)
|
list(APPEND required_vars ${macro_name}_LIBRARY)
|
||||||
endforeach (assembly)
|
endforeach (assembly)
|
||||||
|
|
||||||
|
if (NOT FX_INCLUDE_DIR AND NOT in_tree)
|
||||||
|
list(APPEND required_vars FX_INCLUDE_DIR)
|
||||||
|
find_path(FX_INCLUDE_DIR
|
||||||
|
NAMES fx/misc.h ${FX_FIND_ARGS}
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
PATHS ${FX_SEARCH_PATHS})
|
||||||
|
endif ()
|
||||||
|
|
||||||
unset(FX_FIND_ARGS)
|
unset(FX_FIND_ARGS)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
@@ -106,18 +111,21 @@ if (FX_FOUND)
|
|||||||
set(lib_name ${assembly}${_lib_suffix})
|
set(lib_name ${assembly}${_lib_suffix})
|
||||||
|
|
||||||
if (NOT TARGET FX::${target_name})
|
if (NOT TARGET FX::${target_name})
|
||||||
add_library(FX::${target_name} UNKNOWN IMPORTED)
|
if (TARGET ${assembly})
|
||||||
set_target_properties(FX::${target_name} PROPERTIES
|
add_library(FX::${target_name} ALIAS ${assembly})
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${FX_INCLUDE_DIR}")
|
else ()
|
||||||
target_compile_definitions(FX::${target_name} INTERFACE _CRT_SECURE_NO_WARNINGS=1)
|
add_library(FX::${target_name} UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(FX::${target_name} PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${FX_INCLUDE_DIR}")
|
||||||
|
target_compile_definitions(FX::${target_name} INTERFACE _CRT_SECURE_NO_WARNINGS=1)
|
||||||
|
|
||||||
if (FX_STATIC)
|
if (FX_STATIC)
|
||||||
target_compile_definitions(FX::${target_name} INTERFACE FX_STATIC=1)
|
target_compile_definitions(FX::${target_name} INTERFACE FX_STATIC=1)
|
||||||
|
endif ()
|
||||||
|
set_target_properties(FX::${target_name} PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
|
IMPORTED_LOCATION "${${macro_name}_LIBRARY}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set_target_properties(FX::${target_name} PROPERTIES
|
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
|
||||||
IMPORTED_LOCATION "${${macro_name}_LIBRARY}")
|
|
||||||
set(created_targets ${created_targets} ${assembly})
|
set(created_targets ${created_targets} ${assembly})
|
||||||
endif ()
|
endif ()
|
||||||
endforeach (assembly)
|
endforeach (assembly)
|
||||||
|
|||||||
+2
-1
@@ -26,7 +26,8 @@ def get_arg(name):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
current_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).decode('utf-8').strip()
|
source_dir = get_arg('source-dir')
|
||||||
|
current_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0'], cwd=source_dir).decode('utf-8').strip()
|
||||||
|
|
||||||
build_id = '{}'.format(current_tag)
|
build_id = '{}'.format(current_tag)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user