Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
d7d5e4ce
Commit
d7d5e4ce
authored
17 years ago
by
Anders Carlsson
Browse files
Options
Downloads
Patches
Plain Diff
Improvements to ccc. Patch by Shantonu Sen.
llvm-svn: 46501
parent
00d7cb99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
clang/utils/ccc
+113
-20
113 additions, 20 deletions
clang/utils/ccc
with
113 additions
and
20 deletions
clang/utils/ccc
+
113
−
20
View file @
d7d5e4ce
...
@@ -15,11 +15,11 @@ import sys
...
@@ -15,11 +15,11 @@ import sys
import
subprocess
import
subprocess
def
error
(
message
):
def
error
(
message
):
print
'
ccc:
'
+
message
print
>>
sys
.
stderr
,
'
ccc:
'
+
message
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
run
(
args
):
def
run
(
args
):
print
'
'
.
join
(
args
)
print
>>
sys
.
stderr
,
'
'
.
join
(
args
)
code
=
subprocess
.
call
(
args
)
code
=
subprocess
.
call
(
args
)
if
code
:
if
code
:
sys
.
exit
(
code
)
sys
.
exit
(
code
)
...
@@ -36,38 +36,102 @@ def link(args):
...
@@ -36,38 +36,102 @@ def link(args):
command
=
'
llvm-ld -native
'
.
split
()
command
=
'
llvm-ld -native
'
.
split
()
run
(
command
+
args
)
run
(
command
+
args
)
def
extension
(
path
):
return
path
.
rpartition
(
"
.
"
)[
2
]
def
changeextension
(
path
,
newext
):
components
=
path
.
rpartition
(
"
.
"
)
return
""
.
join
([
components
[
0
],
components
[
1
],
newext
])
def
inferlanguage
(
extension
):
if
extension
==
"
c
"
:
return
"
c
"
elif
extension
==
"
i
"
:
return
"
c-cpp-output
"
elif
extension
==
"
m
"
:
return
"
objective-c
"
elif
extension
==
"
mi
"
:
return
"
objective-c-cpp-output
"
else
:
return
"
unknown
"
def
main
(
args
):
def
main
(
args
):
action
=
'
link
'
action
=
'
link
'
output
=
''
output
=
''
compile_opts
=
[]
compile_opts
=
[]
link_opts
=
[]
link_opts
=
[]
files
=
[]
files
=
[]
save_temps
=
0
language
=
''
i
=
0
i
=
0
while
i
<
len
(
args
):
while
i
<
len
(
args
):
arg
=
args
[
i
]
arg
=
args
[
i
]
# Modes ccc supports
if
arg
==
'
-E
'
:
if
arg
==
'
-E
'
:
action
=
'
preprocess
'
action
=
'
preprocess
'
if
arg
==
'
-c
'
:
if
arg
==
'
-c
'
:
action
=
'
compile
'
action
=
'
compile
'
if
arg
.
startswith
(
'
-print-prog-name
'
):
if
arg
.
startswith
(
'
-print-prog-name
'
):
action
=
'
print-prog-name
'
action
=
'
print-prog-name
'
if
arg
==
'
-o
'
:
if
arg
==
'
-save-temps
'
:
output
=
args
[
i
+
1
]
save_temps
=
1
i
+=
1
if
arg
==
'
--param
'
:
# Options with no arguments that should pass through
if
arg
in
[
'
-v
'
]:
compile_opts
.
append
(
arg
)
link_opts
.
append
(
arg
)
# Options with one argument that should be ignored
if
arg
in
[
'
--param
'
,
'
-arch
'
]:
i
+=
1
i
+=
1
if
arg
[:
2
]
in
[
'
-D
'
,
'
-I
'
,
'
-U
'
]:
# Prefix matches for the compile mode
if
arg
[:
2
]
in
[
'
-D
'
,
'
-I
'
,
'
-U
'
,
'
-F
'
]:
if
not
arg
[
2
:]:
if
not
arg
[
2
:]:
arg
+=
args
[
i
+
1
]
arg
+=
args
[
i
+
1
]
i
+=
1
i
+=
1
compile_opts
.
append
(
arg
)
compile_opts
.
append
(
arg
)
if
arg
[:
2
]
in
[
'
-l
'
,
'
-L
'
,
'
-O
'
]:
if
arg
[:
5
]
in
[
'
-std=
'
]:
compile_opts
.
append
(
arg
)
# Options with one argument that should pass through
if
arg
in
[
'
-include
'
]:
compile_opts
.
append
(
arg
)
compile_opts
.
append
(
args
[
i
+
1
])
i
+=
1
# Prefix matches for the link mode
if
arg
[:
2
]
in
[
'
-l
'
,
'
-L
'
,
'
-O
'
,
'
-F
'
]:
if
arg
==
'
-O
'
:
arg
=
'
-O1
'
if
arg
==
'
-O
'
:
arg
=
'
-O1
'
if
arg
==
'
-Os
'
:
arg
=
'
-O2
'
if
arg
==
'
-Os
'
:
arg
=
'
-O2
'
link_opts
.
append
(
arg
)
link_opts
.
append
(
arg
)
# Options with one argument that should pass through
if
arg
in
[
'
-framework
'
]:
link_opts
.
append
(
arg
)
link_opts
.
append
(
args
[
i
+
1
])
i
+=
1
# Input files
if
arg
==
'
-filelist
'
:
f
=
open
(
args
[
i
+
1
])
for
line
in
f
:
files
.
append
(
line
.
strip
())
f
.
close
()
i
+=
1
if
arg
==
'
-x
'
:
language
=
args
[
i
+
1
]
i
+=
1
if
arg
[
0
]
!=
'
-
'
:
if
arg
[
0
]
!=
'
-
'
:
files
.
append
(
arg
)
files
.
append
(
arg
)
# Output file
if
arg
==
'
-o
'
:
output
=
args
[
i
+
1
]
i
+=
1
i
+=
1
i
+=
1
if
action
==
'
print-prog-name
'
:
if
action
==
'
print-prog-name
'
:
...
@@ -78,21 +142,50 @@ def main(args):
...
@@ -78,21 +142,50 @@ def main(args):
if
not
files
:
if
not
files
:
error
(
'
no input files
'
)
error
(
'
no input files
'
)
if
action
==
'
preprocess
'
:
if
action
==
'
preprocess
'
or
save_temps
:
args
=
compile_opts
+
files
for
i
,
file
in
enumerate
(
files
):
preprocess
(
args
)
if
not
language
:
language
=
inferlanguage
(
extension
(
file
))
if
save_temps
and
action
!=
'
preprocess
'
:
# Need a temporary output file
if
language
==
'
c
'
:
poutput
=
changeextension
(
file
,
"
i
"
);
elif
language
==
'
objective-c
'
:
poutput
=
changeextension
(
file
,
"
mi
"
);
else
:
poutput
=
changeextension
(
file
,
"
tmp.
"
+
extension
(
file
))
files
[
i
]
=
poutput
else
:
poutput
=
output
if
poutput
:
args
=
[
'
-x
'
,
language
,
'
-o
'
,
poutput
,
file
]
+
compile_opts
else
:
args
=
[
'
-x
'
,
language
,
file
]
+
compile_opts
preprocess
(
args
)
# Discard the explicit language after used once
language
=
''
if
action
==
'
compile
'
:
if
action
==
'
compile
'
or
save_temps
:
if
not
output
:
for
i
,
file
in
enumerate
(
files
):
output
=
files
[
0
].
replace
(
'
.c
'
,
'
.o
'
)
if
not
language
:
args
=
[
'
-o
'
,
output
]
+
compile_opts
+
files
language
=
inferlanguage
(
extension
(
file
))
compile
(
args
)
if
save_temps
and
action
!=
"
compile
"
:
# Need a temporary output file
coutput
=
changeextension
(
file
,
"
o
"
);
files
[
i
]
=
coutput
elif
not
output
:
coutput
=
changeextension
(
file
,
"
o
"
)
else
:
coutput
=
output
args
=
[
'
-x
'
,
language
,
'
-o
'
,
coutput
,
file
]
+
compile_opts
compile
(
args
)
language
=
''
if
action
==
'
link
'
:
if
action
==
'
link
'
:
for
i
,
file
in
enumerate
(
files
):
for
i
,
file
in
enumerate
(
files
):
if
'
.c
'
in
file
:
if
extension
(
file
)
!=
"
o
"
:
out
=
file
.
replace
(
'
.c
'
,
'
.o
'
)
out
=
changeextension
(
file
,
"
o
"
)
args
=
[
'
-o
'
,
out
]
+
compile_opts
+
[
file
]
args
=
[
'
-o
'
,
out
,
file
]
+
compile_opts
compile
(
args
)
compile
(
args
)
files
[
i
]
=
out
files
[
i
]
=
out
if
not
output
:
if
not
output
:
...
...
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