Skip to content

Commit 2ab2be9

Browse files
committed
Fix waning when C/C++ files are compiled on Windows
The fix warning text is similar to: ``` cl : Command line warning D9024 : unrecognized source file type 'c_src/xxx.o', object file assumed ```
1 parent c089345 commit 2ab2be9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/pc_compilation.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ compile_each(_State, [], _Type, _Env, {NewBins, CDB}) ->
120120
{lists:reverse(NewBins), lists:reverse(CDB)};
121121
compile_each(State, [Source | Rest], Type, Env, {NewBins, CDB}) ->
122122
Ext = filename:extension(Source),
123-
Bin = pc_util:replace_extension(Source, Ext, ".o"),
123+
Bin = pc_util:replace_extension(Source, Ext, pc_port_specs:object_file_ext()),
124124
Template = select_compile_template(Type, compiler(Ext)),
125125
Cmd = expand_command(Template, Env, Source, Bin),
126126
CDBEnt = cdb_entry(State, Source, Cmd, Rest),

src/pc_port_specs.erl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
sources/1,
3939
target/1,
4040
type/1,
41-
link_lang/1
41+
link_lang/1,
42+
object_file_ext/0
4243
]).
4344
-export_type([spec/0]).
4445

@@ -144,7 +145,8 @@ maybe_switch_extension(_OsType, Target) ->
144145
Target.
145146

146147
port_objects(SourceFiles) ->
147-
[pc_util:replace_extension(O, ".o") || O <- SourceFiles].
148+
Ext = object_file_ext(),
149+
[pc_util:replace_extension(O, Ext) || O <- SourceFiles].
148150

149151
filter_port_spec({ArchRegex, _, _, _}) ->
150152
pc_util:is_arch(ArchRegex);
@@ -232,3 +234,9 @@ port_opt(State, {env, Env}) ->
232234
{env, PortEnv};
233235
port_opt(_State, Opt) ->
234236
Opt.
237+
238+
object_file_ext() ->
239+
case os:type() of
240+
{win32,_} -> ".obj";
241+
_ -> ".o"
242+
end.

0 commit comments

Comments
 (0)