Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pablo Winant
preprocessor
Commits
71672bbd
Commit
71672bbd
authored
1 year ago
by
Pablo Winant
Browse files
Options
Downloads
Patches
Plain Diff
First implementation of extension module.
parent
6ed53ae0
No related branches found
No related tags found
No related merge requests found
Pipeline
#9640
failed
1 year ago
Stage: build
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
meson.build
+1
-1
1 addition, 1 deletion
meson.build
scripts/wasm32.ini
+25
-0
25 additions, 0 deletions
scripts/wasm32.ini
src/DynLib.cc
+73
-0
73 additions, 0 deletions
src/DynLib.cc
src/meson.build
+17
-4
17 additions, 4 deletions
src/meson.build
with
116 additions
and
5 deletions
meson.build
+
1
−
1
View file @
71672bbd
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
project
(
'dynare-preprocessor'
,
'cpp'
,
project
(
'dynare-preprocessor'
,
'cpp'
,
version
:
'6-unstable'
,
version
:
'6-unstable'
,
# NB: update C++ standard in .clang-format whenever the following is modified
# NB: update C++ standard in .clang-format whenever the following is modified
default_options
:
[
'cpp_std=gnu++20'
,
'warning_level=
2
'
],
default_options
:
[
'cpp_std=gnu++20'
,
'warning_level=
0
'
],
meson_version
:
'>=0.64.0'
)
meson_version
:
'>=0.64.0'
)
add_global_arguments
(
'-DPACKAGE_VERSION="'
+
meson
.
project_version
()
+
'"'
,
language
:
'cpp'
)
add_global_arguments
(
'-DPACKAGE_VERSION="'
+
meson
.
project_version
()
+
'"'
,
language
:
'cpp'
)
...
...
This diff is collapsed.
Click to expand it.
scripts/wasm32.ini
0 → 100644
+
25
−
0
View file @
71672bbd
# Cross-compile file for creating a WebAssembly version of the preprocessor
# Requires emscripten to be installed
# Creates a .wasm and .js wrapper under <builddir>/src/
# Can be run locally with node.js using:
# node --no-experimental-fetch dynare-preprocessor.js
[binaries]
cpp
=
'em++'
[host_machine]
system
=
'emscripten'
cpu_family
=
'wasm32'
cpu
=
'wasm32'
endian
=
'little'
[properties]
# It’s necessary to use a different copy of Boost than the one under
# /usr/include, because otherwise GCC headers confuse Clang
#boost_root = '/path/to/boost'
# For accessing the local filesystem
; cpp_args = ['-fwasm-exceptions']
; cpp_link_args = ['--embed-file', 'example1.mod', '-o', 'dynare.html', '-fwasm-exceptions']
; cpp_args = ['-fexceptions']
cpp_args
=
['-fexceptions']
cpp_link_args
=
['-fexceptions']
This diff is collapsed.
Click to expand it.
src/DynLib.cc
0 → 100644
+
73
−
0
View file @
71672bbd
#include
<iostream>
#include
<sstream>
#include
<fstream>
#include
<vector>
#include
<string>
#include
<regex>
#include
<thread>
#include
<algorithm>
#include
<filesystem>
#include
<cstdlib>
#include
<unistd.h>
#include
"ParsingDriver.hh"
#include
"ExtendedPreprocessorTypes.hh"
#include
"ConfigFile.hh"
#include
"ModFile.hh"
std
::
string
preprocess
(
const
std
::
string
&
modfile_string
)
{
// dup2(STDOUT_FILENO, STDERR_FILENO);
// # we capture output completely
std
::
stringstream
buffer
;
std
::
streambuf
*
old
=
std
::
cout
.
rdbuf
(
buffer
.
rdbuf
());
// std::streambuf * old = std::cerr.rdbuf(buffer.rdbuf());
const
string
basename
=
"model"
;
stringstream
modfile
;
modfile
<<
modfile_string
;
bool
debug
=
false
;
bool
no_warn
=
true
;
bool
nostrict
=
true
;
WarningConsolidation
warnings
(
no_warn
);
ParsingDriver
p
(
warnings
,
nostrict
);
unique_ptr
<
ModFile
>
mod_file
=
p
.
parse
(
modfile
,
debug
);
JsonOutputPointType
json
{
JsonOutputPointType
::
nojson
};
JsonFileOutputType
json_output_mode
{
JsonFileOutputType
::
file
};
json
=
JsonOutputPointType
::
parsing
;
json_output_mode
=
JsonFileOutputType
::
standardout
;
bool
onlyjson
=
false
;
// remark: why would writeJsonOutput ever decide to exit ?
mod_file
->
writeJsonOutput
(
basename
,
json
,
json_output_mode
,
false
);
std
::
string
output
=
buffer
.
str
();
// text will now contain "Bla\n"
return
output
;
}
#include
<pybind11/pybind11.h>
namespace
py
=
pybind11
;
PYBIND11_MODULE
(
dynare_preprocessor
,
m
)
{
m
.
doc
()
=
"Dynare Preprocessor"
;
// optional module docstring
m
.
def
(
"preprocess"
,
&
preprocess
,
"Another one"
);
}
This diff is collapsed.
Click to expand it.
src/meson.build
+
17
−
4
View file @
71672bbd
py3_inst
=
import
(
'python'
).
find_installation
(
'python3'
)
pybind11_config
=
find_program
(
'pybind11-config'
)
pybind11_config_ret
=
run_command
(
pybind11_config
,
[
'--includes'
])
pybind11
=
declare_dependency
(
include_directories
:
[
pybind11_config_ret
.
stdout
().
split
(
'-I'
)[
-
1
].
strip
()],
)
python3
=
dependency
(
'python3'
)
boost_dep
=
dependency
(
'boost'
)
boost_dep
=
dependency
(
'boost'
)
## Flex stuff
## Flex stuff
...
@@ -69,7 +79,10 @@ else
...
@@ -69,7 +79,10 @@ else
preprocessor_link_args
=
[]
preprocessor_link_args
=
[]
endif
endif
executable
(
'dynare-preprocessor'
,
preprocessor_src
,
flex_src
,
flexlexer_h
,
bison_src
,
# executable('dynare-preprocessor', preprocessor_src, flex_src, flexlexer_h, bison_src,
include_directories
:
preprocessor_incdir
,
dependencies
:
boost_dep
,
# include_directories : preprocessor_incdir, dependencies : boost_dep,
link_args
:
preprocessor_link_args
,
# link_args : preprocessor_link_args,
install
:
true
)
# install : true)
py3_inst
.
extension_module
(
'dynare_preprocessor'
,
preprocessor_src
,
flex_src
,
flexlexer_h
,
bison_src
,
'DynLib.cc'
,
include_directories
:
preprocessor_incdir
,
dependencies
:
[
boost_dep
,
python3
,
pybind11
],
link_args
:
preprocessor_link_args
,
install
:
true
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment