1616
1717system_compiler () = gcc
1818
19+
20+ function mingw_dir (folders... )
21+ joinpath (
22+ WinRPM. installdir, " usr" , " $(Sys. ARCH) -w64-mingw32" ,
23+ " sys-root" , " mingw" , folders...
24+ )
25+ end
26+
1927"""
2028 julia_compile(julia_program::String; kw_args...)
2129
@@ -105,19 +113,15 @@ function julia_compile(
105113
106114 o_file = julia_program_basename * " .o"
107115 s_file = julia_program_basename * " .$(Libdl. dlext) "
108- if julia_v07
109- e_file = julia_program_basename * (Sys. iswindows () ? " .exe" : " " )
110- else
111- e_file = julia_program_basename * (is_windows () ? " .exe" : " " )
112- end
116+ e_file = julia_program_basename * (iswindows () ? " .exe" : " " )
113117 tmp_dir = " tmp_v$VERSION "
114118
115119 # TODO : these should probably be emitted from julia-config also:
116120 if julia_v07
117- shlibdir = Sys . iswindows () ? Sys. BINDIR : abspath (Sys. BINDIR, Base. LIBDIR)
121+ shlibdir = iswindows () ? Sys. BINDIR : abspath (Sys. BINDIR, Base. LIBDIR)
118122 private_shlibdir = abspath (Sys. BINDIR, Base. PRIVATE_LIBDIR)
119123 else
120- shlibdir = is_windows () ? JULIA_HOME : abspath (JULIA_HOME, Base. LIBDIR)
124+ shlibdir = iswindows () ? JULIA_HOME : abspath (JULIA_HOME, Base. LIBDIR)
121125 private_shlibdir = abspath (JULIA_HOME, Base. PRIVATE_LIBDIR)
122126 end
123127
@@ -137,22 +141,27 @@ function julia_compile(
137141 math_mode == nothing || push! (julia_cmd. exec, " --math-mode=$math_mode " )
138142 depwarn == nothing || (julia_cmd. exec[5 ] = " --depwarn=$depwarn " )
139143 if julia_v07
140- Sys. iswindows () && (julia_program = replace (julia_program, " \\ " , " \\\\ " ))
144+
145+ iswindows () && (julia_program = replace (julia_program, " \\ " , " \\\\ " ))
141146 expr = "
142147 Base.init_depot_path() # initialize package depots
143148 Base.init_load_path() # initialize location of site-packages
144149 empty!(Base.LOAD_CACHE_PATH) # reset / remove any builtin paths
145150 push!(Base.LOAD_CACHE_PATH, abspath(\" $tmp_dir \" )) # enable usage of precompiled files
146151 include(\" $julia_program \" ) # include \" julia_program\" file
147152 empty!(Base.LOAD_CACHE_PATH) # reset / remove build-system-relative paths"
153+
148154 else
149- is_windows () && (julia_program = replace (julia_program, " \\ " , " \\\\ " ))
155+
156+ iswindows () && (julia_program = replace (julia_program, " \\ " , " \\\\ " ))
150157 expr = "
151158 empty!(Base.LOAD_CACHE_PATH) # reset / remove any builtin paths
152159 push!(Base.LOAD_CACHE_PATH, abspath(\" $tmp_dir \" )) # enable usage of precompiled files
153160 include(\" $julia_program \" ) # include \" julia_program\" file
154161 empty!(Base.LOAD_CACHE_PATH) # reset / remove build-system-relative paths"
162+
155163 end
164+
156165 isdir (tmp_dir) || mkpath (tmp_dir)
157166 command = ` $julia_cmd -e $expr `
158167 verbose && println (" Build module image files \" .ji\" in subdirectory \" $tmp_dir \" :\n $command " )
@@ -177,41 +186,25 @@ function julia_compile(
177186 bitness = Int == Int32 ? " -m32" : " -m64"
178187 if shared
179188 command = ` $cc $bitness -shared -o $s_file $(joinpath (tmp_dir, o_file)) $flags `
180- if julia_v07
181- if Sys. isapple ()
182- command = ` $command -Wl,-install_name,@rpath/\" $s_file \" `
183- elseif Sys. iswindows ()
184- command = ` $command -Wl,--export-all-symbols`
185- end
186- else
187- if is_apple ()
188- command = ` $command -Wl,-install_name,@rpath/\" $s_file \" `
189- elseif is_windows ()
190- command = ` $command -Wl,--export-all-symbols`
191- end
189+ if isapple ()
190+ command = ` $command -Wl,-install_name,@rpath/\" $s_file \" `
191+ elseif iswindows ()
192+ command = ` $command -Wl,--export-all-symbols`
192193 end
193194 verbose && println (" Build shared library \" $s_file \" in build directory:\n $command " )
194195 run (command)
195196 end
196197
197198 if executable
198199 command = ` $cc $bitness -DJULIAC_PROGRAM_LIBNAME=\" $s_file \" -o $e_file $cprog $s_file $flags `
199- if julia_v07
200- if Sys. isapple ()
201- command = ` $command -Wl,-rpath,@executable_path`
202- elseif Sys. isunix ()
203- command = ` $command -Wl,-rpath,\$ ORIGIN`
204- end
205- else
206- if is_apple ()
207- command = ` $command -Wl,-rpath,@executable_path`
208- elseif is_unix ()
209- command = ` $command -Wl,-rpath,\$ ORIGIN`
210- end
200+ if isapple ()
201+ command = ` $command -Wl,-rpath,@executable_path`
202+ elseif isunix ()
203+ command = ` $command -Wl,-rpath,\$ ORIGIN`
211204 end
212- if Sys . is_windows ()
213- RPMbindir = Pkg . dir ( " WinRPM " , " deps " , " usr " , " x86_64-w64-mingw32 " , " sys-root " , " mingw " , " bin" )
214- incdir = Pkg . dir ( " WinRPM " , " deps " , " usr " , " x86_64-w64-mingw32 " , " sys-root " , " mingw " , " include" )
205+ if iswindows ()
206+ RPMbindir = mingw_dir ( " bin" )
207+ incdir = mingw_dir ( " include" )
215208 push! (Base. Libdl. DL_LOAD_PATH, RPMbindir) # TODO does this need to be reversed?
216209 ENV [" PATH" ] = ENV [" PATH" ] * " ;" * RPMbindir
217210 command = ` $command -I$incdir `
@@ -225,18 +218,10 @@ function julia_compile(
225218 libfiles = String[]
226219 dlext = " ." * Libdl. dlext
227220 for dir in (shlibdir, private_shlibdir)
228- if julia_v07
229- if Sys. iswindows () || Sys. isapple ()
230- append! (libfiles, joinpath .(dir, filter (x -> endswith (x, dlext), readdir (dir))))
231- else
232- append! (libfiles, joinpath .(dir, filter (x -> contains (x, r" ^lib.+\. so(?:\.\d +)*$" ), readdir (dir))))
233- end
221+ if iswindows () || isapple ()
222+ append! (libfiles, joinpath .(dir, filter (x -> endswith (x, dlext), readdir (dir))))
234223 else
235- if is_windows () || is_apple ()
236- append! (libfiles, joinpath .(dir, filter (x -> endswith (x, dlext), readdir (dir))))
237- else
238- append! (libfiles, joinpath .(dir, filter (x -> ismatch (r" ^lib.+\. so(?:\.\d +)*$" , x), readdir (dir))))
239- end
224+ append! (libfiles, joinpath .(dir, filter (x -> contains (x, r" ^lib.+\. so(?:\.\d +)*$" ), readdir (dir))))
240225 end
241226 end
242227 sync = false
0 commit comments