Allow building on Windows without Cygwin
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Mar 2015 23:59:02 +0000 (23:59 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Mar 2015 23:59:02 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143219

Reviewed by Brent Fulgham.

* AVFoundationSupport.py: Renamed from Source/WebCore/WebCore.vcxproj/MigrateScripts.
Move logic from DerivedSources.make to its own script
(lookFor):
* DerivedSources.make: Paths like /usr/bin don't exist on Windows.
Windows uses del instead of rm -f
Windows doesn't have printf
* WebCore.vcxproj/WebCoreGenerated.make: Pass the CC executable to
build-generated-files.pl
* WebCore.vcxproj/build-generated-files.pl: Export the CC executable as an environment
variable. Don't use /usr/bin.
* WebCore.vcxproj/migrate-scripts.pl: Deleted the MigrateScripts makefile. We don't
need a whole Makefile just to copy 5 files. Moved this logic into migrate-scripts.pl.
(copyFile):
* bindings/scripts/preprocessor.pm:
(applyPreprocessor): Support passing preprocessing flags to the Visual Studio
compiler.
* dom/make_names.pl: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182164 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/AVFoundationSupport.py [moved from Source/WebCore/WebCore.vcxproj/MigrateScripts with 65% similarity]
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.vcxproj/WebCoreGenerated.make
Source/WebCore/WebCore.vcxproj/build-generated-files.pl
Source/WebCore/WebCore.vcxproj/migrate-scripts.pl
Source/WebCore/bindings/scripts/preprocessor.pm
Source/WebCore/dom/make_names.pl

similarity index 65%
rename from Source/WebCore/WebCore.vcxproj/MigrateScripts
rename to Source/WebCore/AVFoundationSupport.py
index 7c5506a..5c1bb2f 100644 (file)
@@ -1,17 +1,19 @@
-# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+#!/usr/bin/python
+
+# Copyright (C) 2015 Apple Inc.  All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
 #
 # 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer. 
+#     notice, this list of conditions and the following disclaimer.
 # 2.  Redistributions in binary form must reproduce the above copyright
 #     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution. 
-# 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+#     documentation and/or other materials provided with the distribution.
+# 3.  Neither the name of Apple puter, Inc. ("Apple") nor the names of
 #     its contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission. 
+#     from this software without specific prior written permission.
 #
 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-.PHONY : all
-all : \
-    $(WEBKIT_OUTPUT)/CodeGenerator.pm \
-    $(WEBKIT_OUTPUT)/IDLParser.pm \
-    $(WEBKIT_OUTPUT)/generate-bindings.pl \
-    $(WEBKIT_OUTPUT)/preprocessor.pm \
-    $(WEBKIT_OUTPUT)/preprocess-idls.pl \
-#
+import sys
+import os
+
 
-MIGRATE_CMD = cp $< $@
+def lookFor(relativePath):
+    return os.path.isfile(os.environ['WEBKIT_LIBRARIES'] + relativePath) or os.path.isfile(os.environ['WEBKITLIBRARIESDIR'] + relativePath)
 
-# Migrate generation scripts
-$(WEBKIT_OUTPUT)/% : $(WEBCORE)/bindings/scripts/%
-       $(MIGRATE_CMD)
+print "/* Identifying AVFoundation Support */"
+if lookFor("/include/AVFoundationCF/AVCFBase.h"):
+    print "#define HAVE_AVCF 1"
+if lookFor("/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h"):
+    print "#define HAVE_AVCF_LEGIBLE_OUTPUT 1"
+if lookFor("/include/AVFoundationCF/AVCFAssetResourceLoader.h"):
+    print "#define HAVE_AVFOUNDATION_LOADER_DELEGATE 1"
index 973fdb0..0abd25c 100644 (file)
@@ -1,3 +1,28 @@
+2015-03-30  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Allow building on Windows without Cygwin
+        https://bugs.webkit.org/show_bug.cgi?id=143219
+
+        Reviewed by Brent Fulgham.
+
+        * AVFoundationSupport.py: Renamed from Source/WebCore/WebCore.vcxproj/MigrateScripts.
+        Move logic from DerivedSources.make to its own script
+        (lookFor):
+        * DerivedSources.make: Paths like /usr/bin don't exist on Windows.
+        Windows uses del instead of rm -f
+        Windows doesn't have printf
+        * WebCore.vcxproj/WebCoreGenerated.make: Pass the CC executable to
+        build-generated-files.pl
+        * WebCore.vcxproj/build-generated-files.pl: Export the CC executable as an environment
+        variable. Don't use /usr/bin.
+        * WebCore.vcxproj/migrate-scripts.pl: Deleted the MigrateScripts makefile. We don't
+        need a whole Makefile just to copy 5 files. Moved this logic into migrate-scripts.pl.
+        (copyFile):
+        * bindings/scripts/preprocessor.pm:
+        (applyPreprocessor): Support passing preprocessing flags to the Visual Studio
+        compiler.
+        * dom/make_names.pl: Ditto.
+
 2015-03-30  Alexey Proskuryakov  <ap@apple.com>
 
         Build fix.
index bab4d6e..bd143b0 100644 (file)
@@ -682,13 +682,13 @@ SVG_BINDING_IDLS = \
     $(WebCore)/svg/SVGZoomEvent.idl
 #
 
-# Windows has specific needs for specifying the path to its interpreters
+PYTHON = python
+PERL = perl
+
 ifeq ($(OS),Windows_NT)
-    PYTHON = /usr/bin/python
-    PERL = /usr/bin/perl
+    DELETE = cmd //C del
 else
-    PYTHON = python
-    PERL = perl
+    DELETE = rm -f
 endif
 # --------
 
@@ -881,7 +881,7 @@ all : XMLViewerCSS.h
 XMLViewerCSS.h : xml/XMLViewer.css
        $(PYTHON) $(InspectorScripts)/cssmin.py <"$(WebCore)/xml/XMLViewer.css" > ./XMLViewer.min.css
        $(PERL) $(InspectorScripts)/xxd.pl XMLViewer_css ./XMLViewer.min.css XMLViewerCSS.h
-       rm -f ./XMLViewer.min.css
+       $(DELETE) XMLViewer.min.css
 
 # --------
 
@@ -892,7 +892,7 @@ all : XMLViewerJS.h
 XMLViewerJS.h : xml/XMLViewer.js
        $(PYTHON) $(InspectorScripts)/jsmin.py <"$(WebCore)/xml/XMLViewer.js" > ./XMLViewer.min.js
        $(PERL) $(InspectorScripts)/xxd.pl XMLViewer_js ./XMLViewer.min.js XMLViewerJS.h
-       rm -f ./XMLViewer.min.js
+       $(DELETE) XMLViewer.min.js
 
 # --------
 
@@ -1169,15 +1169,17 @@ DEDICATEDWORKERGLOBALSCOPE_CONSTRUCTORS_FILE = ./DedicatedWorkerGlobalScopeConst
 IDL_FILES_TMP = ./idl_files.tmp
 IDL_ATTRIBUTES_FILE = $(WebCore)/bindings/scripts/IDLAttributes.txt
 
-# The following two lines get a space character stored in a variable.
-# See <http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html>.
-space :=
-space +=
+# The following lines get a newline character stored in a variable.
+# See <http://stackoverflow.com/questions/7039811/how-do-i-process-extremely-long-lists-of-files-in-a-make-recipe>.
+define NL
+
+
+endef
 
 $(SUPPLEMENTAL_MAKEFILE_DEPS) : $(PREPROCESS_IDLS_SCRIPTS) $(BINDING_IDLS) $(PLATFORM_FEATURE_DEFINES) DerivedSources.make
-       printf "$(subst $(space),,$(patsubst %,%\n,$(BINDING_IDLS)))" > $(IDL_FILES_TMP)
+       $(foreach f,$(BINDING_IDLS),echo $(f)>>$(IDL_FILES_TMP)$(NL))
        $(call preprocess_idls_script, $(PREPROCESS_IDLS_SCRIPTS)) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --idlFilesList $(IDL_FILES_TMP) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) --windowConstructorsFile $(WINDOW_CONSTRUCTORS_FILE) --workerGlobalScopeConstructorsFile $(WORKERGLOBALSCOPE_CONSTRUCTORS_FILE) --dedicatedWorkerGlobalScopeConstructorsFile $(DEDICATEDWORKERGLOBALSCOPE_CONSTRUCTORS_FILE) --supplementalMakefileDeps $@
-       rm -f $(IDL_FILES_TMP)
+       $(DELETE) $(IDL_FILES_TMP)
 
 JS%.h : %.idl $(JS_BINDINGS_SCRIPTS) $(IDL_ATTRIBUTES_FILE) $(WINDOW_CONSTRUCTORS_FILE) $(WORKERGLOBALSCOPE_CONSTRUCTORS_FILE) $(PLATFORM_FEATURE_DEFINES)
        $(call generator_script, $(JS_BINDINGS_SCRIPTS)) $(IDL_COMMON_ARGS) --defines "$(FEATURE_DEFINES) $(ADDITIONAL_IDL_DEFINES) LANGUAGE_JAVASCRIPT" --generator JS --idlAttributesFile $(IDL_ATTRIBUTES_FILE) --supplementalDependencyFile $(SUPPLEMENTAL_DEPENDENCY_FILE) $<
@@ -1191,7 +1193,7 @@ all : InspectorOverlayPage.h
 InspectorOverlayPage.h : InspectorOverlayPage.html InspectorOverlayPage.css InspectorOverlayPage.js
        $(PYTHON) $(InspectorScripts)/inline-and-minify-stylesheets-and-scripts.py $(WebCore)/inspector/InspectorOverlayPage.html ./InspectorOverlayPage.combined.html
        $(PERL) $(InspectorScripts)/xxd.pl InspectorOverlayPage_html ./InspectorOverlayPage.combined.html InspectorOverlayPage.h
-       rm -f ./InspectorOverlayPage.combined.html
+       $(DELETE) InspectorOverlayPage.combined.html
 
 all : CommandLineAPIModuleSource.h
 
@@ -1199,7 +1201,7 @@ CommandLineAPIModuleSource.h : CommandLineAPIModuleSource.js
        echo "//# sourceURL=__WebInspectorCommandLineAPIModuleSource__" > ./CommandLineAPIModuleSource.min.js
        $(PYTHON) $(InspectorScripts)/jsmin.py <$(WebCore)/inspector/CommandLineAPIModuleSource.js >> ./CommandLineAPIModuleSource.min.js
        $(PERL) $(InspectorScripts)/xxd.pl CommandLineAPIModuleSource_js ./CommandLineAPIModuleSource.min.js CommandLineAPIModuleSource.h
-       rm -f ./CommandLineAPIModuleSource.min.js
+       $(DELETE) CommandLineAPIModuleSource.min.js
 
 # Web Replay inputs generator
 
@@ -1269,10 +1271,7 @@ ifeq ($(OS),Windows_NT)
 
 all : WebCoreHeaderDetection.h
 
-WebCoreHeaderDetection.h : DerivedSources.make
-       echo "/* Identifying AVFoundation Support */" > $@
-       if [ -f "$(WEBKIT_LIBRARIES)/include/AVFoundationCF/AVCFBase.h" ]||[ -f "$(WEBKITLIBRARIESDIR)/include/AVFoundationCF/AVCFBase.h" ]; then echo "#define HAVE_AVCF 1" >> $@; else echo >> $@; fi
-       if [ -f "$(WEBKIT_LIBRARIES)/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h" ]||[ -f "$(WEBKITLIBRARIESDIR)/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h" ]; then echo "#define HAVE_AVCF_LEGIBLE_OUTPUT 1" >> $@; else echo >> $@; fi
-       if [ -f "$(WEBKIT_LIBRARIES)/include/AVFoundationCF/AVCFAssetResourceLoader.h" ]||[ -f "$(WEBKITLIBRARIESDIR)/include/AVFoundationCF/AVCFAssetResourceLoader.h" ]; then echo "#define HAVE_AVFOUNDATION_LOADER_DELEGATE 1" >> $@; else echo >> $@; fi
+WebCoreHeaderDetection.h : $(WebCore)/AVFoundationSupport.py DerivedSources.make
+       $(PYTHON) $(WebCore)/AVFoundationSupport.py > $@
 
 endif # Windows_NT
index 5f9fc55..e6768ba 100644 (file)
@@ -3,7 +3,7 @@ make:
     @if errorlevel 1 exit 1\r
     @echo XXWebCoreGeneratedXX > "%ConfigurationBuildDir%\buildfailed"\r
 \r
-    perl build-generated-files.pl "%ConfigurationBuildDir%" "%WebKit_Libraries%" windows "%PlatformArchitecture%"\r
+    perl build-generated-files.pl "%ConfigurationBuildDir%" "%WebKit_Libraries%" windows "%PlatformArchitecture%" "$(CC)"\r
     perl migrate-scripts.pl "%ConfigurationBuildDir%\obj%PlatformArchitecture%\WebCore\scripts"\r
     @cmd /C copyForwardingHeaders.cmd cg cf\r
     @cmd /C copyWebCoreResourceFiles.cmd\r
index 311bca0..a6d20db 100755 (executable)
@@ -28,6 +28,7 @@
 
 use strict;
 use Cwd;
+use Config;
 use File::Path qw(make_path);
 use File::Spec;
 
@@ -80,5 +81,11 @@ if ($ARGV[2] eq 'cairo') {
     $ENV{'PLATFORM_FEATURE_DEFINES'} = File::Spec->catfile($SDKROOT, 'tools', 'vsprops', 'FeatureDefines.props');
 }
 
+if ($Config{osname} eq 'MSWin32') {
+    my $ccPath = `where $ARGV[4]`;
+    chomp($ccPath);
+    $ENV{CC} = $ccPath;
+}
+
 my $DERIVED_SOURCES_MAKEFILE = File::Spec->catfile($XSRCROOT, 'DerivedSources.make');
-system('/usr/bin/make', '-f', $DERIVED_SOURCES_MAKEFILE, '-j', $NUMCPUS) and die "Failed to build $DERIVED_SOURCES_MAKEFILE: $!";
+system('make', '-f', $DERIVED_SOURCES_MAKEFILE, '-j', $NUMCPUS) and die "Failed to build $DERIVED_SOURCES_MAKEFILE: $!";
index 50191f0..53dffce 100644 (file)
@@ -28,6 +28,7 @@
 
 use strict;
 use Cwd;
+use File::Copy;
 use File::Path qw(make_path);
 use File::Spec;
 
@@ -60,5 +61,17 @@ $ENV{'WEBCORE'} = $XSRCROOT;
 $ENV{'WebCore'} = $XSRCROOT;
 $ENV{'WEBKIT_OUTPUT'} = $XDSTROOT;
 
-my $MIGRATE_SCRIPTS_MAKEFILE = File::Spec->catfile($XSRCROOT, 'WebCore.vcxproj', 'MigrateScripts');
-system('/usr/bin/make', '-f', $MIGRATE_SCRIPTS_MAKEFILE, '-j', $NUMCPUS) and die "Failed to build $MIGRATE_SCRIPTS_MAKEFILE: $!";
+sub copyFile {
+    my $filename = shift;
+    my $source = File::Spec->catfile($XSRCROOT, "bindings", "scripts", $filename);
+    my $destination = File::Spec->catfile($XDSTROOT, $filename);
+    if (! -e $destination || (stat($source))[9] > (stat($destination))[9]) { # 9th element is file modification time
+        copy($source, $destination);
+    }
+}
+
+copyFile("CodeGenerator.pm");
+copyFile("IDLParser.pm");
+copyFile("generate-bindings.pl");
+copyFile("preprocessor.pm");
+copyFile("preprocess-idls.pl");
index 868dcbc..759ebfa 100644 (file)
@@ -54,7 +54,11 @@ sub applyPreprocessor
         } else {
             $preprocessor = "/usr/bin/gcc";
         }
-        push(@args, qw(-E -P -x c++));
+        if ($Config::Config{"osname"} eq "MSWin32") {
+            push(@args, qw(/EP));
+        } else {
+            push(@args, qw(-E -P -x c++));
+        }
     }
 
     if ($Config::Config{"osname"} eq "darwin") {
@@ -71,7 +75,7 @@ sub applyPreprocessor
     @macros = map { "-D$_" } @macros;
 
     my $pid = 0;
-    if ($Config{osname} eq "cygwin" || $Config{osname} eq 'MSWin32') {
+    if ($Config{osname} eq "cygwin") {
         # This call can fail if Windows rebases cygwin, so retry a few times until it succeeds.
         for (my $tries = 0; !$pid && ($tries < 20); $tries++) {
             eval {
@@ -84,6 +88,8 @@ sub applyPreprocessor
                 sleep 1;
             }
         };
+    } elsif ($Config::Config{"osname"} eq "MSWin32") {
+        $pid = open2(\*PP_OUT, \*PP_IN, $preprocessor, @args, @macros, $fileName);
     } else {
         $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), @args, @macros, $fileName);
     }
index 3bf9af4..0d7a36f 100755 (executable)
@@ -62,17 +62,23 @@ my %extensionAttrs = ();
 
 require Config;
 
-my $gccLocation = "";
+my $ccLocation = "";
 if ($ENV{CC}) {
-    $gccLocation = $ENV{CC};
+    $ccLocation = $ENV{CC};
 } elsif (($Config::Config{"osname"}) =~ /solaris/i) {
-    $gccLocation = "/usr/sfw/bin/gcc";
+    $ccLocation = "/usr/sfw/bin/gcc";
 } elsif ($Config::Config{"osname"} eq "darwin" && $ENV{SDKROOT}) {
-    chomp($gccLocation = `xcrun -find cc -sdk '$ENV{SDKROOT}'`);
+    chomp($ccLocation = `xcrun -find cc -sdk '$ENV{SDKROOT}'`);
 } else {
-    $gccLocation = "/usr/bin/cc";
+    $ccLocation = "/usr/bin/cc";
+}
+
+my $preprocessor = "";
+if ($Config::Config{"osname"} eq "MSWin32") {
+    $preprocessor = "\"$ccLocation\" /EP";
+} else {
+    $preprocessor = $ccLocation . " -E -x c++";
 }
-my $preprocessor = $gccLocation . " -E -x c++";
 
 GetOptions(
     'tags=s' => \$tagsFile,