Menu

[r167]: / helpers.cs  Maximize  Restore  History

Download this file

258 lines (214 with data), 9.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
using System;
using System.IO;
using System.Linq;
partial class PortableBuilder : SolutionProjectBuilder
{
static void Main(String[] args)
{
try
{
var fi = typeof(PortableBuilder).GetField("supportOnlyOs", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
String onlyPlatform = ( fi != null ) ? fi.GetValue(null).ToString(): null;
String[] OSes;
if (onlyPlatform != null)
OSes = new string[] { onlyPlatform };
else
OSes = new String[] { "windows", "android" };
foreach (String platform in OSes)
{
bool isWindows = platform == "windows";
if( m_solution != null && !m_solution.name.EndsWith( "_" + platform ) )
continue;
group( Path.GetDirectoryName(ProjectName) );
String projName = Path.GetFileName(ProjectName);
project(projName + "_" + platform);
configurations("Debug", "Release");
if (isWindows)
{
platforms("Win32", "x64");
vsver(2013);
toolset("v120");
}
else
{
platforms("ARM", "ARM64");
vsver(2015);
androidapilevel("android-21");
useofstl("system");
toolset("Gcc_4_9");
configureLanguage();
filter( "platforms:ARM" );
thumbmode( EThumbMode.ARM );
filter();
}
targetdir("../bin/$(Configuration)_$(Platform)_" + platform);
targetname(projName);
objdir("../../obj/$(Configuration)_$(Platform)_" + platform + "_" + projName);
//filter("Debug");
// //defines("_DEBUG");
// symbols("on");
// optimize("off");
// CCpp_CodeGeneration_EnableFunctionLevelLinking();
// Ccpp_Optimization_WholeProgramGeneration();
// Ccpp_Optimization_Optimization();
//filter("Release");
// defines("NDEBUG");
// optimize("speed");
//filter();
BuildProject(platform);
}
}
catch (Exception ex)
{
ConsolePrintException(ex, args);
}
} //Main
/// <summary>
/// Probes for language which this class specifies, by default uses plain "C".
/// </summary>
static void configureLanguage()
{
String lang = "C";
var lanF = typeof( PortableBuilder ).GetField( "language", System.Reflection.BindingFlags.Static );
if( lanF != null && lanF.GetType() == typeof( String ) )
lang = lanF.GetValue( null ) as String;
if( lang == "C" )
{
language();
buildoptions( "-std=gnu99" );
}
else
{
language( "C++" );
}
}
/// <summary>
/// Adds file and configures it to be compiled with nasm.exe
/// </summary>
/// <param name="file">.nasm file to add</param>
static void nasmFiles(params String[] _files)
{
foreach ( String file in _files )
{
files(file);
filter("files:" + file);
String name = Path.GetFileNameWithoutExtension(file);
String objFile = "$(ProjectDir)$(IntermediateOutputPath)" + Path.GetFileNameWithoutExtension(file) + ".obj";
buildrule(new CustomBuildRule()
{
Message = "Assembling " + file,
Command = @"nasm.exe -f win32 -d OBJ_FORMAT_win32 -i ia32/ " + file + " -o " + objFile,
Outputs = objFile,
AdditionalInputs = "ia32/nasm.h"
});
}
filter();
}
/// <summary>
/// Adds assembly files for particular platform. For Windows uses yasm.exe (external tool), for Android uses gcc itself.
/// </summary>
/// <param name="platform">windows or android</param>
static void ffmpeg_asmFiles( String platform )
{
bool isWindows = platform == "windows";
String[] pickDirs;
if( isWindows )
pickDirs = new String[] { "x86" };
else
pickDirs = new String[] { "arm" };
String projectDir = Path.GetFileName( Path.GetDirectoryName( m_project.getFullPath() ) );
foreach( String asmDir in pickDirs )
{
String asmExt = ".asm";
if( asmDir != "x86" )
asmExt = ".S";
files( asmDir + "/*.c" );
files( asmDir + "/*" + asmExt );
// test projects
removefiles( "**test.c");
// template files, included from another .c files
removefiles( "**template.c");
if( asmDir == "x86")
removefiles( "x86/x86inc.asm", "x86/x86util.asm" );
foreach( FileInfo fi in getCurrentProjectFiles( asmDir + "/**" + asmExt ) )
{
selectConfigurations( fi );
String dir = Path.GetDirectoryName( fi.relativePath );
String name = Path.GetFileNameWithoutExtension( fi.relativePath );
String objExt = ".obj";
if( !isWindows )
objExt = ".o";
String uniqueObjName = Path.Combine( Path.GetDirectoryName( fi.relativePath ), Path.GetFileNameWithoutExtension( fi.relativePath ) ).Replace( "\\", "_" ) + objExt;
String objFile = "$(ProjectDir)$(IntermediateOutputPath)" + uniqueObjName;
String exe = ( isWindows ) ? "yasm.exe" : "$(ClangToolExe)";
String asmParams;
if( isWindows )
asmParams = "-f win32 -DPREFIX -I./ -I.// -Pconfig.asm -I " + projectDir + "/x86/";
else
asmParams = "-I . -march=armv7-a -mfloat-abi=softfp -c";
String fileLongPath = Path.Combine( projectDir, fi.relativePath );
String cmd = exe + " " + asmParams + " -o " + objFile + " " + fileLongPath;
if( !String.IsNullOrEmpty( dir ) )
cmd = "pushd ..\r\n" + cmd + "\r\npopd";
buildrule( new CustomBuildRule()
{
Message = "Assembling '" + fi.relativePath + "'...",
Command = cmd,
Outputs = objFile
} );
}
} //asmDir
} //ffmpeg_asmFiles
/// <summary>
/// Sets ffmpeg project configuration - disables some of warnings, sets up compilation options.
/// </summary>
/// <param name="platform"></param>
static void ffmpeg_setCommonProjectOptions( String platform )
{
defines("_ISOC99_SOURCE", "_FILE_OFFSET_BITS=64", "_LARGEFILE_SOURCE");
defines("HAVE_AV_CONFIG_H", "_USE_MATH_DEFINES", "_CRT_SECURE_NO_WARNINGS");
EnableMultiProcessorBuild();
includedirs("..\\.");
if ( platform == "windows")
{
disablewarnings( "4244", "4127", "4018", "4389", "4146", "4057", "4204", "4706", "4305", "4152", "4324", "4100", "4214", "4554" );
disablewarnings( "4273", "4701" );
defines( "_WIN32_WINNT=0x0502" );
defines( "strtod=avpriv_strtod", "snprintf=avpriv_snprintf", "_snprintf=avpriv_snprintf", "vsnprintf=avpriv_vsnprintf", "inline=__inline", "strtoll=_strtoi64" );
return;
}
String[] warnings = new String[]
{
"declaration-after-statement",
"all",
"disabled-optimization",
"pointer-arith",
"redundant-decls",
"write-strings",
"type-limits",
"undef",
"missing-prototypes",
"no-pointer-to-int-cast",
"strict-prototypes",
"empty-body",
"no-parentheses",
"no-switch",
"no-format-zero-length",
"no-pointer-sign",
"error=format-security",
//"error=implicit-function-declaration",
"error=missing-prototypes",
"error=return-type",
"error=vla",
"format",
"no-maybe-uninitialized"
};
String opts = String.Join( " ", warnings.Select( x => "-W" + x ) );
buildoptions( opts );
//
// -marm is required at least by vp5.c, vp56.c, vp6, might be others as well, but in general arm is faster than thumb -
// see https://stackoverflow.com/questions/11062936/gcc-mthumb-against-marm
//
buildoptions( "-march=armv7-a -marm" );
}
}; //class PortableBuilder