Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
8c246fe5
Unverified
Commit
8c246fe5
authored
Feb 26, 2018
by
Robert Kimball
Committed by
GitHub
Feb 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resource file cleanup (#546)
* working * cleanup
parent
eedea8d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
56 deletions
+31
-56
compiler.cpp
src/ngraph/codegen/compiler.cpp
+10
-13
main.cpp
src/resource/main.cpp
+21
-43
No files found.
src/ngraph/codegen/compiler.cpp
View file @
8c246fe5
...
...
@@ -411,24 +411,21 @@ void codegen::StaticCompiler::configure_search_path()
void
codegen
::
StaticCompiler
::
load_headers_from_resource
()
{
const
string
builtin_root
=
"/$builtin"
;
HeaderSearchOptions
&
hso
=
m_compiler
->
getInvocation
().
getHeaderSearchOpts
();
PreprocessorOptions
&
preprocessor_options
=
m_compiler
->
getInvocation
().
getPreprocessorOpts
();
std
::
set
<
std
::
string
>
header_search_paths
;
for
(
const
HeaderInfo
&
hi
:
header_info
)
for
(
const
string
&
search_path
:
builtin_search_paths
)
{
string
search_path
=
hi
.
search_path
;
string
absolute_path
=
file_util
::
path_join
(
search_path
,
hi
.
header_path
);
string
builtin
=
"/$builtin"
+
absolute_path
;
string
builtin
=
builtin_root
+
search_path
;
hso
.
AddPath
(
builtin
,
clang
::
frontend
::
System
,
false
,
false
);
}
for
(
const
pair
<
string
,
string
>&
header_info
:
builtin_headers
)
{
string
absolute_path
=
header_info
.
first
;
string
builtin
=
builtin_root
+
absolute_path
;
std
::
unique_ptr
<
llvm
::
MemoryBuffer
>
mb
(
llvm
::
MemoryBuffer
::
getMemBuffer
(
h
i
.
header_data
,
builtin
));
llvm
::
MemoryBuffer
::
getMemBuffer
(
h
eader_info
.
second
,
builtin
));
preprocessor_options
.
addRemappedFile
(
builtin
,
mb
.
release
());
if
(
!
contains
(
header_search_paths
,
search_path
))
{
string
builtin
=
"/$builtin"
+
search_path
;
hso
.
AddPath
(
builtin
,
clang
::
frontend
::
System
,
false
,
false
);
header_search_paths
.
insert
(
search_path
);
}
}
}
...
...
src/resource/main.cpp
View file @
8c246fe5
...
...
@@ -100,8 +100,8 @@ int main(int argc, char** argv)
include_paths
.
push_back
({
CLANG_BUILTIN_HEADERS_PATH
,
{},
true
});
include_paths
.
push_back
({
"/usr/include/x86_64-linux-gnu"
,
{
"asm"
,
"sys"
,
"bits"
,
"gnu"
}});
include_paths
.
push_back
(
{
"/usr/include"
,
{
"asm"
,
"sys"
,
"bits"
,
"gnu"
}});
include_paths
.
push_back
({
"/usr/include"
,
{
"linux"
,
"asm-generic"
}});
include_paths
.
push_back
(
{
"/usr/include"
,
{
"asm"
,
"sys"
,
"bits"
,
"gnu"
,
"linux"
,
"asm-generic"
}});
include_paths
.
push_back
({
cpp0
,
{
"bits"
}});
include_paths
.
push_back
({
"/usr/include/c++/4.8.2/x86_64-redhat-linux"
,
{
"bits"
}});
include_paths
.
push_back
({
cpp1
,
{
"bits"
,
"ext"
,
"debug"
,
"backward"
}});
...
...
@@ -168,63 +168,41 @@ int main(int argc, char** argv)
if
(
update_needed
)
{
size_t
total_size
=
0
;
size_t
total_count
=
0
;
const
string
prefix
=
"pReFiX"
;
ofstream
out
(
output_path
);
out
<<
"#pragma clang diagnostic ignored
\"
-Weverything
\"\n
"
;
out
<<
"#include <vector>
\n
"
;
out
<<
"namespace ngraph
\n
"
;
out
<<
"{
\n
"
;
out
<<
"
static const uint8_t header_resources[]
=
\n
"
;
out
<<
"
const std::vector<std::string> builtin_search_paths
=
\n
"
;
out
<<
" {
\n
"
;
vector
<
pair
<
size_t
,
size_t
>>
offset_size_list
;
size_t
offset
=
0
;
size_t
total_size
=
0
;
size_t
total_count
=
0
;
for
(
const
ResourceInfo
&
path
:
include_paths
)
{
for
(
const
string
&
header_file
:
path
.
files
)
out
<<
"
\"
"
<<
path
.
search_path
<<
"
\"
,
\n
"
;
}
out
<<
" };
\n
"
;
out
<<
" const std::vector<std::pair<std::string, std::string>> builtin_headers =
\n
"
;
out
<<
" {
\n
"
;
for
(
const
ResourceInfo
&
path
:
include_paths
)
{
for
(
const
string
&
header_path
:
path
.
files
)
{
string
header_data
=
read_file_to_string
(
header_
file
);
string
base_path
=
header_file
.
substr
(
path
.
search_path
.
size
()
+
1
);
header_data
=
rewrite_header
(
header_data
,
bas
e_path
);
string
header_data
=
read_file_to_string
(
header_
path
);
string
relative_path
=
header_path
.
substr
(
path
.
search_path
.
size
()
+
1
);
header_data
=
rewrite_header
(
header_data
,
relativ
e_path
);
// header_data = uncomment(header_data);
total_size
+=
header_data
.
size
();
total_count
++
;
// data layout is triplet of strings containing:
// 1) search path
// 2) header path within search path
// 3) header data
// all strings are null terminated and the length includes the null
// The + 1 below is to account for the null terminator
dump
(
out
,
path
.
search_path
.
c_str
(),
path
.
search_path
.
size
()
+
1
);
offset_size_list
.
push_back
({
offset
,
path
.
search_path
.
size
()
+
1
});
offset
+=
path
.
search_path
.
size
()
+
1
;
dump
(
out
,
header_file
.
c_str
(),
header_file
.
size
()
+
1
);
offset_size_list
.
push_back
({
offset
,
header_file
.
size
()
+
1
});
offset
+=
header_file
.
size
()
+
1
;
dump
(
out
,
header_data
.
c_str
(),
header_data
.
size
()
+
1
);
offset_size_list
.
push_back
({
offset
,
header_data
.
size
()
+
1
});
offset
+=
header_data
.
size
()
+
1
;
out
<<
" {"
;
out
<<
"
\"
"
<<
header_path
<<
"
\"
,
\n
R
\"
"
<<
prefix
<<
"("
<<
header_data
<<
")"
<<
prefix
<<
"
\"
},
\n
"
;
}
}
out
<<
" };
\n
"
;
out
<<
" struct HeaderInfo
\n
"
;
out
<<
" {
\n
"
;
out
<<
" const char* search_path;
\n
"
;
out
<<
" const char* header_path;
\n
"
;
out
<<
" const char* header_data;
\n
"
;
out
<<
" };
\n
"
;
out
<<
" std::vector<HeaderInfo> header_info
\n
"
;
out
<<
" {
\n
"
;
for
(
size_t
i
=
0
;
i
<
offset_size_list
.
size
();)
{
out
<<
" {(char*)(&header_resources["
<<
offset_size_list
[
i
++
].
first
;
out
<<
"]), (char*)(&header_resources["
<<
offset_size_list
[
i
++
].
first
;
out
<<
"]), (char*)(&header_resources["
<<
offset_size_list
[
i
++
].
first
<<
"])},
\n
"
;
}
out
<<
" };
\n
"
;
out
<<
"}
\n
"
;
cout
.
imbue
(
locale
(
""
));
cout
<<
"Total size "
<<
total_size
<<
" in "
<<
total_count
<<
" files
\n
"
;
...
...
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