Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Dukboot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
dukboot
Dukboot
Commits
d407e811
Unverified
Commit
d407e811
authored
May 20, 2017
by
Will Hilton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing out a `makeheaders` build system.
parent
a5e817c1
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
62 additions
and
42 deletions
+62
-42
Makefile
Makefile
+31
-0
src/app_assert_safe_path.c
src/app_assert_safe_path.c
+2
-0
src/app_push_argv.c
src/app_push_argv.c
+2
-0
src/app_push_dir.c
src/app_push_dir.c
+3
-0
src/app_push_environ.c
src/app_push_environ.c
+2
-0
src/app_push_trusted_function.c
src/app_push_trusted_function.c
+2
-0
src/app_stash_global_string.c
src/app_stash_global_string.c
+2
-0
src/app_unstash_global_string.c
src/app_unstash_global_string.c
+2
-0
src/autogenerated.h
src/autogenerated.h
+0
-35
src/c_join_paths.c
src/c_join_paths.c
+3
-0
src/c_read_script_file.c
src/c_read_script_file.c
+3
-0
src/main.c
src/main.c
+2
-7
src/native_import.c
src/native_import.c
+2
-0
src/native_print.c
src/native_print.c
+2
-0
src/queue_create.c
src/queue_create.c
+2
-0
src/queue_push_queue.c
src/queue_push_queue.c
+2
-0
No files found.
Makefile
0 → 100644
View file @
d407e811
CC
=
gcc
CFLAGS
=
-fopenmp
-I
./lib/duktape
-Os
-pedantic
-std
=
c99
-Wall
-fstrict-aliasing
-fomit-frame-pointer
-D_GNU_SOURCE
ifeq
($(OS),Windows_NT)
BIN
=
dukboot.exe
else
BIN
=
dukboot
endif
SRC
=
$(
wildcard
src/
*
.c
)
HEADERS
=
$(SRC:.c=.h)
OBJS
=
$(SRC:.c=.o)
DEPS
=
$(
wildcard
lib/duktape/
*
.o
)
main
:
$(HEADERS) $(OBJS) $(DEPS)
$(CC)
$(CFLAGS)
-o
$(BIN)
$(OBJS)
$(DEPS)
$(LDFLAGS)
-lm
%.h
:
$(SRC)
makeheaders src/
*
.c
%.o
:
%.c
$(CC)
$<
-c
-o
$@
$(CFLAGS)
clean
:
$(
foreach
c,
$(BINS)
,
$(RM)
$(c)
;
)
$(RM)
$(OBJS)
$(HEADERS)
test
:
@
./test.sh
.PHONY
:
test all clean install uninstall
src/app_assert_safe_path.c
View file @
d407e811
#include <duktape.h>
#include "app_assert_safe_path.h"
duk_int_t
app_assert_safe_path
(
duk_context
*
ctx
)
{
// Safety check filename argument
duk_require_string
(
ctx
,
-
1
);
...
...
src/app_push_argv.c
View file @
d407e811
#include <duktape.h>
#include "app_push_argv.h"
int
app_push_argv
(
duk_context
*
ctx
,
int
argc
,
char
*
argv
[])
{
// Construct argv array
duk_idx_t
argv_idx
=
duk_push_array
(
ctx
);
...
...
src/app_push_dir.c
View file @
d407e811
#include "duktape.h"
#include <dirent.h>
#include "app_push_dir.h"
int
app_push_dir
(
duk_context
*
ctx
)
{
// Safety check filename argument
app_assert_safe_path
(
ctx
);
...
...
src/app_push_environ.c
View file @
d407e811
#include "duktape.h"
#include "app_push_environ.h"
int
app_push_environ
(
duk_context
*
ctx
)
{
int
keylen
=
0
;
char
*
val
;
...
...
src/app_push_trusted_function.c
View file @
d407e811
#include "duktape.h"
#include "app_push_trusted_function.h"
int
app_push_trusted_function
(
duk_context
*
ctx
)
{
// Safety check filename argument
app_assert_safe_path
(
ctx
);
...
...
src/app_stash_global_string.c
View file @
d407e811
#include "duktape.h"
#include "app_stash_global_string.h"
void
app_stash_global_string
(
duk_context
*
ctx
,
char
*
name
)
{
duk_push_global_stash
(
ctx
);
// summon the magic stash object
duk_get_global_string
(
ctx
,
name
);
...
...
src/app_unstash_global_string.c
View file @
d407e811
#include "duktape.h"
#include "app_unstash_global_string.h"
void
app_unstash_global_string
(
duk_context
*
ctx
,
char
*
name
)
{
duk_push_global_stash
(
ctx
);
// summon the magic stash object
// TODO: Throw an error if property not found. (Right now just returns undefined)
...
...
src/autogenerated.h
deleted
100644 → 0
View file @
a5e817c1
// Autogenerated by the Queen of Hearts, who cut off everyone's head and added a semicolon.
#ifndef FILE_WONDERLAND
#define FILE_WONDERLAND
// Forward declare everything
duk_int_t
app_assert_safe_path
(
duk_context
*
ctx
);
int
app_push_argv
(
duk_context
*
ctx
,
int
argc
,
char
*
argv
[]);
int
app_push_dir
(
duk_context
*
ctx
);
int
app_push_environ
(
duk_context
*
ctx
);
int
app_push_trusted_function
(
duk_context
*
ctx
);
void
app_stash_global_string
(
duk_context
*
ctx
,
char
*
name
);
void
app_unstash_global_string
(
duk_context
*
ctx
,
char
*
name
);
char
*
c_join_paths
(
const
char
*
base
,
const
char
*
filename
);
int
c_read_script_file
(
const
char
*
joined_path
,
char
**
message
,
char
**
buffer
,
size_t
*
bytesRead
);
int
native_import
(
duk_context
*
ctx
,
const
char
*
filename
);
duk_ret_t
native_print
(
duk_context
*
ctx
);
int
queue_create
(
duk_context
*
ctx
,
char
*
name
);
int
queue_push_queue
(
duk_context
*
ctx
,
char
*
name
);
// Include everything
#include "app_assert_safe_path.c"
#include "app_push_argv.c"
#include "app_push_dir.c"
#include "app_push_environ.c"
#include "app_push_trusted_function.c"
#include "app_stash_global_string.c"
#include "app_unstash_global_string.c"
#include "c_join_paths.c"
#include "c_read_script_file.c"
#include "native_import.c"
#include "native_print.c"
#include "queue/queue_create.c"
#include "queue/queue_push_queue.c"
#endif
/* !FILE_WONDERLAND */
src/c_join_paths.c
View file @
d407e811
#include "duktape.h"
#include <libgen.h>
#include "c_join_paths.h"
char
*
c_join_paths
(
const
char
*
base
,
const
char
*
filename
)
{
int
base_len
=
strlen
(
base
);
int
filename_len
=
strlen
(
filename
);
...
...
src/c_read_script_file.c
View file @
d407e811
#include <stdio.h>
#include "duktape.h"
#include "c_read_script_file.h"
int
c_read_script_file
(
const
char
*
joined_path
,
char
**
message
,
char
**
buffer
,
size_t
*
bytesRead
)
{
// Open the file
FILE
*
pFile
=
fopen
(
joined_path
,
"rb"
);
...
...
src/main.c
View file @
d407e811
...
...
@@ -4,11 +4,6 @@
extern
char
**
environ
;
// Include dependencies
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <libgen.h>
#include <string.h>
#ifdef _WIN32
// @see [1]
...
...
@@ -19,7 +14,7 @@ extern char **environ;
#include "duktape.h"
// Include all our functions
#include "
autogenerated
.h"
#include "
main
.h"
int
main
(
int
argc
,
char
*
argv
[]
/* char *environ[] */
)
{
// Re-open stdin and stdout in binary mode
...
...
@@ -32,7 +27,7 @@ int main(int argc, char *argv[] /* char *environ[] */) {
#endif
if
(
argc
<
2
)
{
printf
(
"Usage: dukboot
s
file-to-eval.js
\n
"
);
printf
(
"Usage: dukboot file-to-eval.js
\n
"
);
printf
(
"Yup. Pretty basic API at the moment.
\n
"
);
exit
(
0
);
}
...
...
src/native_import.c
View file @
d407e811
#include "duktape.h"
#include "native_import.h"
int
native_import
(
duk_context
*
ctx
,
const
char
*
filename
)
{
char
*
message
=
NULL
;
char
*
buffer
=
NULL
;
...
...
src/native_print.c
View file @
d407e811
#include "duktape.h"
#include "native_print.h"
duk_ret_t
native_print
(
duk_context
*
ctx
)
{
duk_push_string
(
ctx
,
" "
);
duk_insert
(
ctx
,
0
);
...
...
src/queue
/queue
_create.c
→
src/queue_create.c
View file @
d407e811
#include "duktape.h"
#include "queue_create.h"
int
queue_create
(
duk_context
*
ctx
,
char
*
name
)
{
// Create a top-level Array on the heap stash with the given name
duk_push_heap_stash
(
ctx
);
...
...
src/queue
/queue
_push_queue.c
→
src/queue_push_queue.c
View file @
d407e811
#include "duktape.h"
#include "queue_push_queue.h"
int
queue_push_queue
(
duk_context
*
ctx
,
char
*
name
)
{
duk_push_heap_stash
(
ctx
);
duk_get_prop_string
(
ctx
,
-
1
,
name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment