<commit_before>#------------------------------------------------------------------------
# (The MIT License)
#
# Copyright (c) 2008-2020 Rhomobile, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# http://rhomobile.com
#------------------------------------------------------------------------

require 'rubygems'

namespace "config" do

	task :set_win32_platform do
		$current_platform = "win32" unless $current_platform
		$sdk = "win32"
	end

	task :win32 => ["config:set_win32_platform", "config:win32:qt", "config:common"] do
		$rubypath = get_ruby_path
		$platformdir = File.join("platform", "win32") 
	    $vcbindir = File.join($platformdir, "bin")
	    $appname = $app_config["name"].nil? ? "Rhodes" : $app_config["name"]
	    $bindir = File.join($app_path, "bin")    

	    $rhobundledir =  File.join($app_path, "RhoBundle")
	    $log_file = $app_config["applog"].nil? ? "applog.txt" : $app_config["applog"]
	    $srcdir =  File.join($bindir, "RhoBundle")
	    $buildcfg = $app_config["buildcfg"] unless $buildcfg
	    $buildcfg = "Release" unless $buildcfg
	    $detoolappflag = $js_application == true ? "js" : "ruby"
	    $tmp_dir = File.join($bindir, "tmp")

	    $targetdir = File.join($bindir, "target", $sdk)
	    $tmpdir  =  File.join($bindir, "tmp")

	    $vcbuild = $config["env"]["paths"]["vcbuild"]
	    $vcbuild = "vcbuild" if $vcbuild.nil?

	    $nsis    = $config["env"]["paths"]["nsis"]
	    $nsis    = "makensis.exe" if $nsis.nil?


		ENV['RHO_PLATFORM'] = $current_platform
		ENV['VCBUILD'] = $vcbuild

	    if $wk_data_dir.nil?
	      $wk_data_dir = File.join($startdir, "libs", "data") #"/Program Files" # its fake value for running without symbol extensions. do not delete
	      begin
	        if $webkit_capability || $symbol_capability
	          require "rhoelements-data"
	          $wk_data_dir = File.join($startdir, "libs", "data")
	        end
	      rescue Exception => e

	      end
	    end

	    $excludelib = ['**/builtinME.rb','**/ServeME.rb','**/dateME.rb','**/rationalME.rb']

	    puts "$sdk [#{$sdk}]"
	end

	namespace "win32" do
		namespace :wm do
		  task :ignore_vsprops do
		    $wm_win32_ignore_vsprops = true
		  end
		end

		task :qt => ["config:qt"] do
		  next if $prebuild_win32
		  $vscommontools = ENV['VS140COMNTOOLS']
		  $qmake_makespec = 'win32-msvc'
	   
		  $qt_project_dir = File.join( $startdir, 'platform','shared','qt')
		end

		task :application do
			$app_version = '1.0'
			$app_version = $app_config["version"] unless $app_config["version"].nil?

			require $startdir + "/lib/rhodes.rb"
			fversion = StringIO.new("", "w+")          
			fversion.write( "#define RHOSIMULATOR_NAME \"RhoSimulator\"\n" )
			fversion.write( "#define RHOSIMULATOR_VERSION \"#{Rhodes::VERSION}\"\n" )
			fversion.write( "#define APPLICATION_NAME \"#{$appname}\"\n" )
			fversion.write( "#define APPLICATION_VERSION \"#{$app_version}\"\n" )
			Jake.modify_file_if_content_changed( File.join($startdir, 'platform','shared','qt','rhodes','RhoSimulatorVersion.h'), fversion )  

			$app_icon_path = $app_path + "/icon/icon.ico"
			$app_icon_path = $startdir + "/res/icons/rhodes.ico" unless File.exists? $app_icon_path
			cp $app_icon_path, $startdir + "/platform/shared/qt/rhodes/resources/rho.ico"

			$qt_icon_path = $app_path + "/icon/icon.png"
			$qt_icon_path = $startdir + "/res/icons/rhodes.png" unless File.exists? $qt_icon_path
			target_icon_path = $startdir + "/platform/shared/qt/rhodes/resources/rho.png"
			if !FileUtils.compare_file($qt_icon_path, target_icon_path)
				cp $qt_icon_path, target_icon_path
			end
			qrcfile = $startdir + "/platform/shared/qt/rhodes/GeneratedFiles/" + $buildcfg + "/qrc_simulator.cpp"
			rm qrcfile if File.exists? qrcfile
		end

	end

end

namespace "build" do
	namespace "win32" do
	def set_vcvarsall()
		if $vcvarsall == nil
			$vs_version = nil
			Jake.run2(File.join($qtdir, 'bin', 'qtdiag'), [' '], {:directory => File.join($qtdir, 'bin'), :nowait => false}) do |line|
			  if line == nil
		      elsif line.include? "MSVC 2015"
		      	$vs_version = 2015
		      	break
		      elsif line.include? "MSVC 2017"
		      	$vs_version = 2017
		      	break
		      elsif line.include? "MSVC 2019"
		      	$vs_version = 2019
		      	break
		      end
		    end
		    puts $vs_version
		    if ($vs_version == nil)
		      	puts "Using QT with unsupported VS version!"
		      	exit 1
		    end

			vcvars = Dir.glob(File.join("C:","Program Files*","Microsoft Visual Studio*","**","vcvarsall.bat"))
			vcvars.each do |batfile|
				if $vs_version == 2015 && batfile.include?("14.0")
					$vcvarsall = batfile
				elsif $vs_version == 2017 && batfile.include?("2017")
					$vcvarsall = batfile
				elsif $vs_version == 2019 && batfile.include?("2019")
					$vcvarsall = batfile
				end
			end
			if ($vcvarsall == nil)
				puts "Can't find vcvarsall.bat in standart locations"
				exit 1
			end
		end
		if File.exists? $vcvarsall
			ENV["RHO_VSCMNTOOLS"] = "\"" + $vcvarsall + "\" x86"
	    else
	    	raise "Can't locate vcvarsall.bat"
	    end
	end

	def runBuldBatFile(bat, extpath)
		set_vcvarsall()
<commit_msg>win32: update for MSVC version setting in build.yml<commit_after>#------------------------------------------------------------------------
# (The MIT License)
#
# Copyright (c) 2008-2020 Rhomobile, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# http://rhomobile.com
#------------------------------------------------------------------------

require 'rubygems'

namespace "config" do

	task :set_win32_platform do
		$current_platform = "win32" unless $current_platform
		$sdk = "win32"
	end

	task :win32 => ["config:set_win32_platform", "config:win32:qt", "config:common"] do
		$rubypath = get_ruby_path
		$platformdir = File.join("platform", "win32") 
	    $vcbindir = File.join($platformdir, "bin")
	    $appname = $app_config["name"].nil? ? "Rhodes" : $app_config["name"]
	    $bindir = File.join($app_path, "bin")    

	    $rhobundledir =  File.join($app_path, "RhoBundle")
	    $log_file = $app_config["applog"].nil? ? "applog.txt" : $app_config["applog"]
	    $srcdir =  File.join($bindir, "RhoBundle")
	    $buildcfg = $app_config["buildcfg"] unless $buildcfg
	    $buildcfg = "Release" unless $buildcfg
	    $detoolappflag = $js_application == true ? "js" : "ruby"
	    $tmp_dir = File.join($bindir, "tmp")

	    $targetdir = File.join($bindir, "target", $sdk)
	    $tmpdir  =  File.join($bindir, "tmp")

	    $vcbuild = $config["env"]["paths"]["vcbuild"]
	    $vcbuild = "vcbuild" if $vcbuild.nil?

	    $nsis    = $config["env"]["paths"]["nsis"]
	    $nsis    = "makensis.exe" if $nsis.nil?


		ENV['RHO_PLATFORM'] = $current_platform
		ENV['VCBUILD'] = $vcbuild

	    if $wk_data_dir.nil?
	      $wk_data_dir = File.join($startdir, "libs", "data") #"/Program Files" # its fake value for running without symbol extensions. do not delete
	      begin
	        if $webkit_capability || $symbol_capability
	          require "rhoelements-data"
	          $wk_data_dir = File.join($startdir, "libs", "data")
	        end
	      rescue Exception => e

	      end
	    end

	    $excludelib = ['**/builtinME.rb','**/ServeME.rb','**/dateME.rb','**/rationalME.rb']

	    puts "$sdk [#{$sdk}]"
	end

	namespace "win32" do
		namespace :wm do
		  task :ignore_vsprops do
		    $wm_win32_ignore_vsprops = true
		  end
		end

		task :qt => ["config:qt"] do
		  next if $prebuild_win32
		  $vscommontools = ENV['VS140COMNTOOLS']
		  $qmake_makespec = 'win32-msvc'
	   
		  $qt_project_dir = File.join( $startdir, 'platform','shared','qt')
		end

		task :application do
			$app_version = '1.0'
			$app_version = $app_config["version"] unless $app_config["version"].nil?

			require $startdir + "/lib/rhodes.rb"
			fversion = StringIO.new("", "w+")          
			fversion.write( "#define RHOSIMULATOR_NAME \"RhoSimulator\"\n" )
			fversion.write( "#define RHOSIMULATOR_VERSION \"#{Rhodes::VERSION}\"\n" )
			fversion.write( "#define APPLICATION_NAME \"#{$appname}\"\n" )
			fversion.write( "#define APPLICATION_VERSION \"#{$app_version}\"\n" )
			Jake.modify_file_if_content_changed( File.join($startdir, 'platform','shared','qt','rhodes','RhoSimulatorVersion.h'), fversion )  

			$app_icon_path = $app_path + "/icon/icon.ico"
			$app_icon_path = $startdir + "/res/icons/rhodes.ico" unless File.exists? $app_icon_path
			cp $app_icon_path, $startdir + "/platform/shared/qt/rhodes/resources/rho.ico"

			$qt_icon_path = $app_path + "/icon/icon.png"
			$qt_icon_path = $startdir + "/res/icons/rhodes.png" unless File.exists? $qt_icon_path
			target_icon_path = $startdir + "/platform/shared/qt/rhodes/resources/rho.png"
			if !FileUtils.compare_file($qt_icon_path, target_icon_path)
				cp $qt_icon_path, target_icon_path
			end
			qrcfile = $startdir + "/platform/shared/qt/rhodes/GeneratedFiles/" + $buildcfg + "/qrc_simulator.cpp"
			rm qrcfile if File.exists? qrcfile
		end

	end

end

namespace "build" do
	namespace "win32" do
	def set_vcvarsall()
		if $vcvarsall == nil
			$vs_version = nil

			msvc_version = $app_config["win32"]["msvc"] if $app_config && $app_config["win32"] && $app_config["win32"]["msvc"]
			if (msvc_version == "2015" or msvc_version == "2017" or msvc_version == "2019")
				$vs_version = msvc_version.to_i
			elsif (msvc_version != nil)
				puts "MSVC version " + msvc_version + " is not supported"
				exit 1
			end

			if ($vs_version == nil)
				puts "Searching for MSVC version from the qtdiag output"
				Jake.run2(File.join($qtdir, 'bin', 'qtdiag'), [' '], {:directory => File.join($qtdir, 'bin'), :nowait => false}) do |line|
				  if line == nil
			      elsif line.include? "MSVC 2015"
			      	$vs_version = 2015
			      	break
			      elsif line.include? "MSVC 2017"
			      	$vs_version = 2017
			      	break
			      elsif line.include? "MSVC 2019"
			      	$vs_version = 2019
			      	break
			      end
			    end
			end

		    puts $vs_version
		    if ($vs_version == nil)
		      	puts "Using QT with unsupported VS version!"
		      	exit 1
		    end

			vcvars = Dir.glob(File.join("C:","Program Files*","Microsoft Visual Studio*","**","vcvarsall.bat"))
			vcvars.each do |batfile|
				if $vs_version == 2015 && batfile.include?("14.0")
					$vcvarsall = batfile
				elsif $vs_version == 2017 && batfile.include?("2017")
					$vcvarsall = batfile
				elsif $vs_version == 2019 && batfile.include?("2019")
					$vcvarsall = batfile
				end
			end
			if ($vcvarsall == nil)
				puts "Can't find vcvarsall.bat in standart locations"
				exit 1
			end
		end
		if File.exists? $vcvarsall
			ENV["RHO_VSCMNTOOLS"] = "\"" + $vcvarsall + "\" x86"
	    else
	    	raise "Can't locate vcvarsall.bat"
	    end
	end

	def runBuldBatFile(bat, extpath)
		set_vcvarsall()

{'fraction_non_alphanumeric': 0.15625245001960017, 'fraction_numerical': 0.01560172481379851, 'mean_word_length': 3.1388708630759248, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '904272', 'n_tokens_mistral': 4866, 'n_tokens_neox': 4216, 'n_words': 1110}